PHP文件上传验证

My php upload script works great and is validated for everything from file type to size except if no file exists. You can just hit the submit button and it will send blank data to the upload script. I was trying this:

if (!is_uploaded_file($HTTP_POST_FILES['ufile1']['name']))
{
        header("location:../index.php?code=no_file");
}

It won't work :(

Any way of getting this to work? -mike

What I use is the file_exists($name_of_submitted_file) function at the end to see whether or not the file has been successfully uploaded.

Check the error code:

http://www.php.net/manual/en/features.file-upload.errors.php

if ($_FILES['ufile1']['error'] == UPLOAD_ERR_NO_FILE) { /* no file */ }

Note that you should already be checking the error code to make sure that it's UPLOAD_ERR_OK on files that you actually acccept.

Also, $HTTP_POST_FILES is deprecated in favour of $_FILES these days. That signifies to me that you probably want to find a newer tutorial.