Answer the question
In order to leave comments, you need to log in
How to overcome the "failed to open stream" error?
Transferred the site to a new server and after that the download of files fell off. The code is generally standard and worked fine before (I won't add it here yet)
Gives " Warning: imagepng(images/upload/1090d639d14df68959c5a1ccb0e47556/logo.png): failed to open stream: Permission denied in /var/www/.... "
Checked the file paths. I even set the rights to 777, but it did not help. There is an assumption that the temporary file is not written correctly, but I don’t know how to check. Only var_dump($_FILES["logo"]); but it gives the correct information - both the name and the weight of the file.
I ask for advice, what else can I check and in what ways can I check the sources of problems?
Answer the question
In order to leave comments, you need to log in
There is a suspicion that imagepng() is trying to write to a place where it does not have rights.
Try using images/upload...
an absolute path instead. Check again if there are rights. And not only on the root images folder, but also on nested ones.
Permission denied in /var/www/.... those are permissions !
if you have this on your local machine and, as a rule, linux hosts , then open the rights for reading and writing
The list of measures if the error "Failed to open stream: access denied" appears.
1. Find out the php error code. To do this, place this code at the top of your php.
ini_set('error_reporting', E_ALL);ini_set('display_errors', 1);ini_set('display_startup_errors', 1);
2. The folder should have access 777. Check it out.
3. The tag must have the attribute enctype = "multipart/form-data" method = "post".
4. Open and view the $_FILES array on the server.
print_r($_FILES);
5. Open and view the $_FILES array on the client.
file = document.getElementById("get_avatar").files[0];parts = file.name.split('.');
var a = file.size;var b = parts.pop();var c = file.type;alert(a+b+c);
<form enctype="multipart/form-data" method="post">
6. Check the rights of the user and user group on the directory.
cd /var/www/your_site/user
ls -l
Read more at profi.spage.me/php/check-file-input-on-php-and-jqu...
In your case, check the permissions on the images/upload/ directory 1090d639d14df68959c5a1ccb0e47556, permissions should be 777 and check the permissions of the user and user group on this directory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question