Problem with uploading in PHP

Asked

Viewed 993 times

5

In an input of type file, the tmp file is not being generated.

this and the array generated by PHP

Array ( [name] => desin3.jpg [type] => image/jpeg [tmp_name] => C:\xampp\tmp\phpE0D5.tmp [error] => 0 [size] => 30420 )

however the file phpE0D5.tmp is not created in the folder xampp\tmp generating an error in the method

   move_uploaded_file

error:

Warning (2): move_uploaded_file(): The second argument to copy() function cannot be a    directory [APP\Controller\DocumentsController.php, line 184]
Warning (2): move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\phpE0D5.tmp' to 'C:\xampp\htdocs\site\app\UploadFiles\1' [APP\Controller\DocumentsController.php, line 184]
  • Your form is: enctype="Multipart/form-data" ?

2 answers

3

Tries to activate the error Reporting to check what’s going wrong, or test the permission with:

if (!is_writeable('uploads/' . $_FILES['image']['name'])) {
   die("Cannot write to destination file");
}
  • then how much the authorization to write in the destination file is ok , the problem and that is not created the file . tmp

3


By the error description, the problem is that you are passing only the directory as the second parameter to move_uploaded_file. You need to pass a full path including the file name at the destination location.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.