Php file upload problems remain unsolved after permission modification
Source: Internet
Author: User
For questions about uploading php files, after the permission limit is modified, ex.html still does not provide the foreground Upload control: & lt; html & gt; & lt; body & gt; & lt; formaction = & quot; ex. php & quot; method = & quot; post & quot; enctype = & quot; multipart/form-php file upload problem. The problem persists after the permission is modified.
Ex.html provides the front-end Upload control:
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.
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.