To save the form through Ajax, everything OK, test also passed, but found that the file did not upload success! Then there is the question of whether to upload files with Ajax.
Look through the data and get the result: no
But at the same time also found a solution, is to use the way to the IFRAME to submit the form, that is, the implementation of no refresh submission form can upload files!
One, HTML code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <meta http-equiv=" Content-type " Content= "text/html; Charset=utf-8 "/> <title> no refresh submit form </title> <script type=" Text/javascript "> <!-- Function Callback (str) { alert (str); } //--></script> <body> <form name= "Form1" method= "POST" ac Tion= ". /post.php "target=" Post_frame "enctype=" Multipart/form-data "> <iframe name= ' post_frame ' id=" Post_frame " Style= "Display:none;" mce_style= "Display:none;" ></iframe> <input type= "file" Name= "img"/> <input name= "power[]" type= "text"/> <i Nput type= "Submit" value= "complete the above modifications" name= "submit"/> </form> </body> |
Second, PHP code (processing code)
here the code would like how to write how to write, but the execution of this in the HMTL page should be a performance, this time to use the last page of the function callback ()
Echo ("<script type=" Text/javascript) >parent.callback (' Operation successful! ') </script> "); |