After a file is uploaded, the following code does not redirect the page: HTMLcode & lt; inputtype = & quot; file & quot; name = & quot; file & quot; id = & quot; file & quot;/& gt; & lt; inputtyp
The code is as follows:
HTML code
PHP code
If ($ _ FILES ["file"] ["type"] = "image/gif ") | ($ _ FILES ["file"] ["type"] = "image/jpeg ") | ($ _ FILES ["file"] ["type"] = "image/pjpeg ") | ($ _ FILES ["file"] ["type"] = "image/png ")) & ($ _ FILES ["file"] ["size"] <2000000) {if ($ _ FILES ["file"] ["error"]> 0) {echo "Return Code :". $ _ FILES ["file"] ["error"]."
";}Else {$ picture = $ _ FILES [" file "] [" name "] ;}} else {echo" select a valid Format (gif, jpeg, and png) the file size cannot exceed 2 MB! ";}
Click upload to execute the above Php statement, but the page jumps. How can we prevent page jumps? Or can I implement the same function in other languages?
------ Solution --------------------
A jump will be generated during submission. you can use the submitted plug-in framework and pop-up window to cover up this phenomenon.
------ Solution --------------------
Search for swfupload and mooUpload.
------ Solution --------------------
Upload files asynchronously through the plug-in. eg: uploadify, swfupload, etc.
------ Solution --------------------
Do you want to upload files on the same page,
If you upload data on the same page, you can
Upload. php
PHP code
0) {echo "Return Code:". $ _ FILES ["file"] ["error"]."
";}Else {$ picture = $ _ FILES [" file "] [" name "] ;}} else {echo" select a valid Format (gif, jpeg, and png) the file size cannot exceed 2 MB! ";}}
------ Solution --------------------
Add a target = "" attribute to form and a hidden iframe tag.
After processing, parent. fun () calls the parent window and the response result is OK.
------ Solution --------------------
Set the action in form to xxx. php, and add html and php to xxx. php. when submitting the file, go to xxx. php on the current page for processing. If there are other data, you can save the temporary data $ tmp =$ _ POST and display it. Although it is a little troublesome, it implements a false jump.
------ Solution --------------------
Use the plug-in to search for ajaxfileupload. js.