Friday, January 26, 2024

[SOLVED] Chmod 666 and access denied for getimagesize

Issue

First of all, this is not a duplicate of : Permission denied on getimagesize

I got following code, where I sat an chmod for the image, and then I wan't to get it's size.

@chmod($path."/".$filename, '0666');
getimagesize($path . "/" . $filename);

But if I set a chmod, I'm receiving this error message:

failed to open stream: Permission denied in[...]

What is the problem? All files and the directory has the same group and owner - www-data.


Solution

Actually do you really need to chmod before getimagesize?

if so, maybe u can try putting umask before chmod. something like this?

$old = umask(0); 
chmod($path,0777);
umask($old);


Answered By - NineAllexis
Answer Checked By - Willingham (WPSolving Volunteer)