开发者

PHP - uploading images not working. Folder owner issue

开发者 https://www.devze.com 2023-01-23 22:26 出处:网络
I have one issue in one ofmy site. When I upload an image, it creates a folder 开发者_开发技巧and then uploading imagesinside the folder. Creating folder is working fine for me, but image can not be u

I have one issue in one of my site. When I upload an image, it creates a folder 开发者_开发技巧and then uploading images inside the folder. Creating folder is working fine for me, but image can not be uploaded. move_uploaded_files is returning false without any error message.

When I checked manually, All folders have proper 777 permission. When folder is created by my code, owner is "apache".

But, when I created a folder manually via ftp, then owner is my username "aayushi", for this folder, upload image is working fine.

Any idea how can I fix the issue? OR how can I give rights to "apache" owner to upload images...

Thanks in advance.


When a folder is created, the owner will be the user who created the folder - in your ftp client, this is the user you logged in as; in PHP, this will be the user the PHP script runs as (in this case, the apache user). Most likely, your problem is the umask setting of Apache when it creates these folders. Setting the umask is covered in the PHP manual.

If you can find a copy of Sklar and Trachtenberg's "PHP Cookbook" somewhere, check out Recipe 19.11 ("Making New Directories") for a bit more discussion on how this works - there may be other tutorials as well, but this is one I found to be pretty clear.

0

精彩评论

暂无评论...
验证码 换一张
取 消