Hi there. Having a small issue in formulating a file upload to my directory. I have properly added the extension to my mysql database (added along with other registration information), but am having a problem putting the file in the directory. Everything else works perfectly, but can't seem to properly move the uploaded file to my directory.
If anyone can spot my oversight, I would be very grateful. Thanks in advance for taking a moment to provide your input.
Here is the relevant php:
$user_pic = $_FILES['user_pic'];
$id = mysql_insert_id();
$newname = "avatar.jpg";
$location = "members/$id/pictures/$newname";
mkdir("members/$id/pictures", 0755, true);
$name = $_FILES['user_pic']['name'];
$tmp_name = $_FILES['user_pic']['tmp_name'];
And the form portion:
<input type='hidden' name='MAX_FILE_SIZE' value='16777216'>
<td width="521"><input name="user_pic" type="file" class="formFields" size="42" /> 2mb max</td>
Thanks again for looking at my problem.
Have you used is_uploaded_file() to check if a file was actually uploaded before trying to move it to its final location?
What errors are you getting?
echo out (or use var_dump() ) the value of $FILES['userpic'['error'] for an error value.
Have you checked the file permissions for the destination folder?
when using var_dump for both:
I get a 'NULL' value. I'm not sure why there is no temp file? The permissions are properly aligned, as well: Both the directories and the script are set to 0755.
Thanks for any insight. I really appreciate the support.
Sorry. I made an elementary mistake: forgetting to set the enctype to "multipart/form-data". Thank you for your insights into properly checking for errors.