开发者

PHP move_uploaded_file failing for unknown reason

开发者 https://www.devze.com 2023-01-20 22:48 出处:网络
I have an PHP website on a RHEL5/CentOS dedicated server. The website is located at /var/www/html/beta

I have an PHP website on a RHEL5/CentOS dedicated server. The website is located at /var/www/html/beta

I have a script:

/var/www/html/beta/scri开发者_StackOverflow中文版ptA.php

which calls a function in

/var/www/html/beta/code/inc/functions.php

The function uses move_uploaded_file() as follows:

$status = move_uploaded_file($imagetmp_name,$destinationPath);

Printing these values shows:

imagetmp_name=/tmp/phpiECxB6
destinationPath=in_upload/images/907770756_publicpage.jpg
status=false

Which I thought should have worked since 'in_upload/images' exists:

drwxr-xr-x  5 root root   4096 Oct 19 07:40 in_upload

and

drwxr-xr-x  2 root root  4096 Oct 19 07:40 images

What am I doing wrong?


You don't have writing permisions to in_upload neither images, only for root.

Use

chmod a+w in_upload
chmod a+w images

or change that directories' owner/group to the user, under which is apache running. example:

chown apache:apache in_upload
chmod g+w in_upload
0

精彩评论

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

关注公众号