简体   繁体   中英

Uploading a file to a specific location PHP

I am using the following line to upload a file with a file name taken from a MySQL query. It correctly adds the file to the images folder

move_uploaded_file($file_tmp,"images/".$_SESSION['loggedStudent']['studentID'].".".$file_ext);

However, I want to put the images in to a folder within the 'images' folder called 'profilepics'

But the following doesn't work. The image doesn't appear in the folder

move_uploaded_file($file_tmp,"images/profilepics/".$_SESSION['loggedStudent']['studentID'].".".$file_ext);

Is this a permission issue or is my code wrong? How can I rectify this? I'm using MacOS and running Apache on it

$destFile = "/root/mysite/upload_files/".$_FILES['file']['name'];
move_uploaded_file( $_FILES['file']['tmp_name'], $destFile );

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