if(isset($_FILES['doc_1'])&&!empty($_FILES['doc_1']['name'])) { $pathinfo = pathinfo($_FILES['doc_1']['name']); //$new_name = $pathinfo['filename'].'_'.$novie_id.'.'.$pathinfo['extension']; $target = "../docs/"; $target = $target . basename( $_FILES['doc_1']['name']); echo $target; $uploadOk=1; $extension = $pathinfo['extension']; if($extension=="jpg" OR $extension=="jpeg" OR $extension=="JPG" OR $extension=="GIF" OR $extension=="gif" OR $extension=="PNG" OR $extension=="png" OR $extension=="doc" or $extension=="docx" or $extension=="pdf" OR $extension=="xls" OR $extension=="xlsx" OR $extension=="ppt" OR $extension=="pptx" OR $extension=="txt" OR $extension=="pub" OR $extension=="wps" or $extension=="bmp" OR $extension=="BMP") { $uploadOk = 1; } else { $uploadOk = 0; //header("Location:doc_badfile.php"); //exit(); } $upload_dir = "../docs/"; if (file_exists($upload_dir) && is_writable($upload_dir)) { echo "you're good to go"; } else { echo 'Upload directory is not writable, or does not exist.'; } if(!move_uploaded_file($_FILES['doc_1']['name'], $target)) { header("Location:doc_noupload.php"); exit(); } echo "OK"; } }
When I comment out the "header("Location:doc_no_upload.php)" dynamic so I can see the target and read all of the other indicators I've been fooling with, there shouldn't be anything keeping this file from uploading.
I've been looking at this for an hour and half. I've got other scripts that follow the same format - no problem. But this one hates me for some reason and I can't figure out what's wrong.
File permissions on target directory are set to 777 so that's good.
Gentlemen, I did get it to work by simply changing the name of the file field. Before I had:
<input name="dir_1" type="file" size="61">
I changed that to:
<input name="attachment_1" type="file" size="61">
When I did that, the skies cleared, the sun came up and the birds began to sing.
Perhaps, "dir" being referenced as a reserved word, was a dealbreaker. At this point, that's what I'm leaning towards as far as an explanation, but I got it done and I appreciate your help.
<input name="dir_1" type="file" size="61">
I changed that to:
<input name="attachment_1" type="file" size="61">
When I did that, the skies cleared, the sun came up and the birds began to sing.
Perhaps, "dir" being referenced as a reserved word, was a dealbreaker. At this point, that's what I'm leaning towards as far as an explanation, but I got it done and I appreciate your help.