views:

39

answers:

3

move_uploaded_file() won't work for me anymore, it was working fine and just stopped out of nowhere. Is there a way for me to check why it's not working anymore? Here's what I currently have, but it only returns TRUE or FALSE.

$status = move_uploaded_file($tempFile, $targetFile);
if($status) {
  echo 'its good';
} else {
  echo 'it failed';
}

I know the path is 100% correct and the directory is CHMOD 755. Is there anything I might be doing wrong?

+1  A: 

Maybe this will work:

if(!move_uploaded_file($_FILES['attachement']['tmp_name'], $uploadfile)) {

echo 'Your file was not uploaded please try again
here are your debug informations:
'.print_r($_FILES);

      } else {

          echo 'image succesfully uploaded!';

      } 
dfilkovi
A: 

Check your error reporting level (see error_reporting function). You should get a warning or notice that's a bit more descriptive.

Also, check that the user your PHP script runs as (usually the server's user, which is nobody or www-data on a lot of systems, but YMMV) owns the directory. With 755, only the owner of the directory can write to it.

notJim
A: 

Permissions of 755 means that only the owner of the directory can write to that directory.

So the question is, who is the owner and as what user is the web-server / php running?

If they don´t match, you can either change the ownership or the group (also changing the permissions to 775).

jeroen