IFrame No refresh file upload is actually in the current page to open the Upload Program page, a bit like Ajax partial refresh a, but we put it in the iframe page upload, and we put the IFRAME page to hide.
One of the most primitive and simplest examples of IFRAME uploads:
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.
Front desk upload page index.html, mainly a form with a JS callback function. When uploading a file, the method, Enctype property of the form form must be the same as the following code. Then set the value of target to the name of the IFRAME, so that no flush upload file can be implemented.
| The code is as follows |
Copy Code |
Uploading files
|
Background upload processing page uploadfile.php, this code for simple upload code, no error and exception handling. After the upload code execution, to tell the parent page has been uploaded, so, in this page called the parent page callback function callbackfunction, this function can have parameters, form their own definition.
| The code is as follows |
Copy Code |
Set_time_limit (0); if ($_server[' Request_method ']== ' POST ') { Move_uploaded_file ($_files["Test_file" ["Tmp_name"], DirName ($_server[' script_filename '). " /uploadtemp/". $_files["Test_file" ["name"]); echo ""; } ?> |
The above is the use of an IFRAME to implement a non-flush upload file simple method, want a robust program needs to be refined
Example 2
PHP uploads files using IFRAME and returns values to parent frame
Fresh water is actually used to do the FA. Just see that there are children's shoes on the blog have this written. Just put it on the back.
| The code is as follows |
Copy Code |
if ($result) { echo "Upload succeeded!" File path is: ". $file 2; Echo ''; Echo '; } |
After the file upload is successful, write the file path to a hidden domain (IMG) and then use the DOM principle to send the value in the hidden field to the IMG text box of the parent frame's form Form1:
OK, then take a look at fresh water.
Freshwater editors are tinymce, so there's a little bit different.
My form page:
| The code is as follows |
Copy Code |
|
The IFRAME is also on this page.
In the PHP processing that my IFRAME is submitted to:
| The code is as follows |
Copy Code |
$pasteJS = "n"; Echo $pasteJS; |
The uploaded file is then run to the TinyMCE edit box. The upload file path is also staged through UserData until it is written to the database. The path to save this piece, also in the IFRAME submitted to the PHP processing file, where fresh water is not much to write.
http://www.bkjia.com/PHPjc/631565.html www.bkjia.com true http://www.bkjia.com/PHPjc/631565.html techarticle iframe No refresh file upload is actually in the current page to open the Upload Program page, a bit like Ajax partial refresh a, but we put it in the IFRAME page upload, while we ...