简体   繁体   中英

PHP 7.0 move_uploaded_file() doesn't work

I'm working on my own VPS server. My codes are down there. I changed the folder permissions to 777. I am using PHP 7.0 and apache2. I tried turning it off in Safe mode. I don't see files in the Temp folder. It also does not move to the folder I specified. Where am I doing wrong?

-Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/var/www/) in Unknown on line 0, referer: http://localhost:8080/

-File upload error - unable to create a temporary file in Unknown on line 0, referer: http://localhost:8080/

i am new user on apache2

//$_FILES["UploadImage]["name"] = eg. image.png

$path = '/var/www/uploads/';

$yuklenecek_dosya = $path . basename($_FILES['UploadImage']['name']);
var_dump(move_uploaded_file($_FILES['UploadImage']['tmp_name'], $yuklenecek_dosya));
// result : bool->false

I tried to produce the solution simply. I saw that the permits I gave were not working. I did the following respectively.

php.ini -> open_basedir = none
php.ini -> system_temp_dir = "/ var / www / tmp /"
chmod 0777 / var / www / tmp /
chmod 0777 / var / www / uploads
and change php script

$ path = '/ var / www / uploads /';

this is work know. Thank you everyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM