In the preceding example, a temporary copy of the uploaded file is created in the PHP temporary folder on the server. The temporary copy file will disappear at the end of the script. To save the uploaded file, we need to copy it to another location :? Phpif ($ _ FILES [file] [type] imagegif) | ($ _ FILES [file] [type
In the preceding example, a temporary copy of the uploaded file is created in the PHP temporary folder on the server. The temporary copy file will disappear at the end of the script. To save the uploaded file, we need to copy it to another location :? Phpif ($ _ FILES [file] [type] = image/gif) | ($ _ FILES [file] [type
Save the uploaded file
In the above example, a temporary copy of the uploaded file is created in the PHP temporary folder on the server.
The temporary copy file will disappear at the end of the script. To save the uploaded file, we need to copy it to another location:
0) { echo "Return Code: " . $_FILES["file"]["error"] . "
"; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; echo "Type: " . $_FILES["file"]["type"] . "
"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } }else { echo "Invalid file"; }?>
The above script checks whether the file already exists. If it does not exist, copy the file to the specified folder.
Note: You must create an "upload" folder under the directory. Otherwise, an error will occur.
The above content can be found in W3C, and the next step is to combine PHP and JqueryMobile to upload images.
I thought it would be easy to add Mobile stuff, but the problem arises: After JqueryMobile is used, infinite Loading occurs,
The reason is that JQM asynchronously submits the form. You only need to add data-ajax = "false" to the form.
The complete steps are as follows:
First, index. php on the user page: