I'm working on a file upload method. But i suddenly start to get the following error, The only thing I changed was the file name. I reverted it back, but the error still persists.
Does anyone know how to solve this?
The error message is:
Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory in /hermes/bosnaweb14a/b1717/ipg.plantationkeyartcorn/kittyrescuetnr/docs/upload.php on line 13
Warning: move_uploaded_file(): Unable to move '/tmp/phpJki8OC' to '/' in /hermes/bosnaweb14a/b1717/ipg.plantationkeyartcorn/kittyrescuetnr/docs/upload.php on line 13 Fail
my php looks like this
<?php
$file_upload="true";
$file_up_size=$_FILES['file_up'][size];
$file_destination=$REQUEST['file_type'];
$file_new_name=$REQUEST['file_name'];
$file_name=$_FILES[file_up][name];
**$add="$file_destination/$file_new_name"; // the path with the file name where the file will be stored**
if($file_upload=="true"){
if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)){
echo print_r($file_new_name);
}else{echo "Fail";}
}else{
echo $msg;
}
?>
Well, since you are using superglobal array $_REQUEST
incorrectly (notice the underscore in the name), your $add
variable evaluates to just a slash. Which is a root directory.
Hence the errors - it is a directory after all and your script probably don't have write access to it anyway (which is a good thing).