[PHP] How to Use JqueryMobile + PHP to upload images on mobile Web pages

Source: Internet
Author: User
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:

 
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.