JQuery Mobile + PHP implementation file Upload _php instance

Source: Internet
Author: User
Very simple a small example of jQuery mobile + PHP upload via Hyper Global $_files, and then use the Move_uploaded_file () method to move the uploaded image to a folder under the local server,

Here's the HTML and PHP code

Copy the Code code as follows:











Campus Festival


Home





Innovative experiments






Copy the Code code as follows:
<?php
if ($_files["file" ["error"] > 0)
{
echo "Return Code:". $_files["File" ["Error"]. "
";
}
Else
{
echo "Upload:". $_files["File" ["Name"]. "
";
echo "Type:". $_files["File" ["type"]. "
";
echo "Size:". ($_files["File" ["Size"]/1024). The 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"];
}
}
}
?>

The code is very simple, but the use of the process found a problem, I have tried for a long time can not upload
Asked the small partner, found that the problem is insufficient file permissions, thereby restricting the Web page upload pictures to the folder. So the solution is to get rid of the permissions of the folder.

Copy the Code code as follows:
$ cd/var/www
$ sudo chmod-r 777 HTML

OK, now it's time to upload the file to the server's folder.

  • Related Article

    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.