After modifying the permission limit, you still cannot determine whether ex.html provides the foreground Upload control: & lt; html & gt; & lt; body & gt; & lt; formaction & quot; ex. php & quot; method & quot; post & quot; enctype & quot; multipartform-data & quot; & gt; & lt; labelfor & q php file upload problems, the permission is not resolved after modification.
Ex.html provides the front-end Upload control:
Ex. php background handler:
If ($ _ FILES ["file"] ["error"]> 0)
{
Echo "Error:". $ _ FILES ["file"] ["error"]."
";
}
Else
{
If ($ _ FILES ["file"] ["type"] = "application/pdf ")
{
If (file_exists ("/home/sss/document/". $ _ FILES ["file"] ["name"])
{
Echo $ _ FILES ["file"] ["naem"]. "already exists ";
}
Else
{
Move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], "/home/sss/document /". $ _ FILES ["file"] ["name"]);
Echo "Stored in:". "/home/sss/document/". $ _ FILES ["file"] ["name"];
}
}
}
?>
Error message:
/Warning: move_uploaded_file (/home/php Upload file): failed to open stream: Permission denied in/var/www/html/php/practice/ex. php on line 25 Warning: move_uploaded_file (): unable to move '/tmp/php1GtkFY' to '/home/sss/documentation/abc.pdf' in/var/www/html/php/practice/ex. php on line 25
The document permission is modified to 777. if you still have any questions, please advise.
------ Solution --------------------
Modify/home/sss/document permissions to read/write.
That is, chmod ('/home/sss/documentation', 0666 );
This directory is out of the web scope, and the operating system may not allow anonymous users to grant execution permissions.
------ Solution --------------------
How can you have three files?
1. Upload files to/home/php
2./tmp/php1GtkFY
3./home/sss/document/abc.pdf
Which of the following is a file?
If you upload a/home/php file upload:
$ _ FILES ["file"] ["name"]: upload a file on PHP
$ _ FILES ["file"] ["tmp_name"]: php1GtkFY
Where did abc.pdf come from? There is no rename in your code ?!!
If you are using Linux, use "./home/sss/document/". Otherwise, the system will start from the root directory.
------ Solution --------------------
Maybe apache didn't give you the corresponding permissions. Modify the apache configuration file and grant the corresponding directory permissions.
------ Solution --------------------
I suspect your path is wrong.
The path of the target file is removed.