Upload problem in PHP

5

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

This is the array generated by PHP

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

but the phpE0D5.tmp file is not created in the xampp\tmp folder by generating an error in the

   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' [APP\Controller\DocumentsController.php, line 184]
    
asked by anonymous 06.04.2014 / 20:09

2 answers

3

From 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 filename at the destination location.

    
07.04.2014 / 04:12
3

Try to enable error reporting to check what is going wrong, or test permission with:

if (!is_writeable('uploads/' . $_FILES['image']['name'])) {
   die("Cannot write to destination file");
}
    
06.04.2014 / 20:45