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.