tags:

views:

35

answers:

3

Hello,

Any ideas why this isn't working? I've used it many times before. I have a folder called 'uploads' in the same directory

$target_path = "uploads/";
 $target_path = $target_path . basename( $_FILES['file']['name']); 

 if(! move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
  $error = 1;
 }

The file input form seems to be working, as when i echo out $_POST['file']; the file name is correct

Thanks

A: 

Have you checked the permissions of the uploads folder? For uploads it usually needs permissions of 777 (Sometimes written as rwxrwxrwx), however I would try 755 or 775 first as there are security implications of allow full write access to global users.

Gazler
+2  A: 

Make sure that:

  • You have specified the encoding type enctype="multipart/form-data" in the form
  • The folder uploads has write permissions, chmod to 755
  • Try prefixing the path with $_SERVER['DOCUMENT_ROOT']
Sarfraz
Thanks man, completely forgot the enctype!
@user195257: You are welcome :)
Sarfraz
A: 

Check if you have write privileges set to your uploads folder.

Mikulas Dite