File (from form) not selected<

liunx

Guest
$upload_file = $HTTP_POST_FILES['flocation']['name']; echo $upload_file;
$temp = $HTTP_POST_FILES['flocation']['tmp_name'];
$extension = substr($upload_file, -4);

if($upload_file == "") {
// NO UPLOAD
} else {
// UPLOAD
}

Hi, I was wondering what's wrong with the above code (or if there's a better solution). I have a form with a field <input type="file" name="flocation"> and then the above carries out the form when it's submitted. I need to check if the user left it blank or not but I can't seem to get the above to work. I'd be greatful for your help. Thanxjust checking:

your form has the enctype attribute set to "multipart/form-data"?


I don't know much about the PHP part - have a look at this in the PHP manual. (<!-- m --><a class="postlink" href="http://uk2.php.net/manual/en/features.file-upload.php#features.file-upload.post-method">http://uk2.php.net/manual/en/features.f ... ost-method</a><!-- m -->)you can use is_uploaded_file() to check.

if (is_uploaded_file($_FILES['flocation']['tmp_name'])){I have a simple uploader script if you would like it.
Email me at <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->.
 
Back
Top