1 year ago

#283057

test-img

user18447340

move_uploaded_file() is not storing my image file in the required destination folder

I have a folder called uploads inside my root directory (C:\xampp\htdocs). I am trying to implement the php function move_uploaded_file(), to store my image file inside that folder. This is my code:

$folder="/uploads";
try{
   $moved=move_uploaded_file($_FILES['file']['tmp_name'][0],$folder.'/'.$_FILES['file']['name'][0]);
}
catch(Exception $e) {
   echo $e->getMessage();  //shows nothing
}
if($moved)
    echo "Moved to location successfully";
else
    echo $folder.'/'.$_FILES['file']['name'][0]; // shows /uploads/business-man.png

I have double checked the file_name, the tmp_name. They are correct. Where am I going wrong?

php

move-uploaded-file

0 Answers

Your Answer

Accepted video resources