tags:

views:

17

answers:

1
move_uploaded_file($_FILES['imgUploader']['tmp_name'],"images/".$name.'.'.$imgExt)

None of the arguments return nil or anything, but it doesn't move the item to the specified folder. Do I have to be more specific with the tmp_name location? I've tried different chmods to see if it works, but 775 and 755 do not work.

It worked locally, but stopped working when I uploaded to my domain.

A: 

per the documentation on php.net for 'move_uploaded_files', the function does NOT produce an error/warning if the first parameter ($filename) is invalid. so if you do something like this:

if(!move_uploaded_files($_FILES['imgUploaded']['tmp_name'],"images/".$name.".".$img_ext)){
 exit("move_uploaded_files did not succeed!");
}else{
 exit("move uploaded_files worked!");
}

Then you can at least see if the function is failing. If it is failing, and you have PHP set to show warnings (which it IS by default), you will get a warning with more details about why it failed if the second parameter ($destination) is invalid. Otherwise, if it fails but has no warning output then you know the uploaded file is invalid (which is usually the result of trying to write to a directory with permissions set to PHP doesn't have write access)

eCaroth