PHP code:
$target_path='uploads/';
//$target_path=$target_path.basename($_FILES['photo']['name']);
$res=move_uploaded_file($_FILES['photo']['tmp_name'],$target_path);
if($res)
//perform insert query
else
//echo 'file not uploaded';
HTML code:
<td colspan="3"> <input type="file" name="photo" id="photo"> </td>
After execution the image file is not moved to target_path folder. Also, The value of $res remains empty.
I need the value of $res as i want to perform insertion query if the variable has “true” as value.
There are no errors in the uploaded file. It exists and so does the target_path. There is no file with same name in target_path folder either.
i simply used copy() instead of move_uploaded_files and it worked. Note that i don’t have enctype mentioned in my form. Don’t know if that was the cause move_uploaded_files wasn’t working. But copy() definitely works without it.
Also consider what oldskool commented above
“$_FILES[‘photo’][‘tmp_name’] will hold the full path to the upload, something like /tmp/asx823ASDfg, so using this syntax will result /upload//tmp/asx823ASDfg, which is an absolute path to a (most likely) unexisting folder. – Oldskool