Use the target property and IFrame of the form form
One, upload the file of a PHP tutorial method.
The method takes a $file parameter, which is the $_files variable obtained from the client, returns the renamed file name, and returns an empty string if the upload fails.
PHP code
function UploadFile ($file) {
Upload path $destinationpath = "./upload/";
if (!file_exists ($destinationpath)) {
mkdir ($destinationpath, 0777); }
Renaming
$filename = Date (' Ymdhis '). '_' . Iconv (' Utf-8 ', ' gb2312 ', basename ($file [' name ']);
if (Move_uploaded_file ($file [' Tmp_name '], $destinationpath. $filename)) {return iconv (' gb2312 ', ' utf-8 ', $filename);
} return ';
}
Second, the client HTML code
Here's where the trick is, add another iframe to implement. The form label form defines a property target, which is interpreted as follows:
[Pre]target Property:
_blank----------New Open window
_self-----------itself
_top------------Main Frame
_parent---------Parent Frame
The custom name-----appears in the frame structure and will open the link within the frame of the name
In this case, the IFRAME name is used, so the form will open the link within the IFRAME when it is submitted (that is, no refresh, exactly
Feel no refresh)
When the form commits, call the Startupload method, which is, of course, the JS definition.
[/pre] [Pre] In addition, we define a span to display the prompt information. The code is as follows:
[/pre]xhtml Code
Import file:
<iframe id= "Upload_target" name= "Upload_target" src= "#" style= "width:0;height:0;border:0px solid #fff;" >iframe &gt;&lt;br/&gt; form&gt; &lt;span id= "Info" &gt;span&gt; &lt;/blockquote&gt;&lt;p&gt;1 2 &lt;br&gt;&lt;/p&gt;&lt;p Align= "left" &gt;&lt;span id= "url" itemprop= "url" &gt;http://www.bkjia.com/phpjc/444809.html&lt;/span&gt;&lt;span Id= "Indexurl" itemprop= "Indexurl" &gt;www.bkjia.com&lt;/span&gt;&lt;span id= "isoriginal" itemprop= "isOriginal" &gt; True&lt;/span&gt;&lt;span id= "Isbasedonurl" itemprop= "Isbasedonurl" &gt;http://www.bkjia.com/phpjc/444809.html &lt;/span&gt;&lt;span id= "Genre" itemprop= "genre" &gt;techarticle&lt;/span&gt;&lt;span id= "description" itemprop= " Description "&gt; A php Tutorial method for uploading files using the target property of form form and iframe one. The method accepts a $file parameter, which is the $_files variable obtained from the client, returns the re ... &lt;/span&gt;&lt;/p&gt;&lt;li &gt;&lt;i class= "Layui-icon" &gt;&amp;# xe63a; </iframe>