PHP - $ _FILES问题

I have the following on a PHP processing file.

if(isset($_FILES['cv'])){
    // run function here
}

Only problem is that the function is getting all the time ... Shouldnt it only be run if a file has been input?

I think that the browser sends an empty field when the user hasn't selected a file, yet it does send it so it is set.

if(isset($_FILES['cv']) && $_FILES['cv']!=null && $_FILES['cv']!=""){
   //Execute
}

The 'cv' key will always be set when a form element of the same name is present. You could test for an empty file instead. Here's one way:

if(isset($_FILES['cv']) && $_FILES['cv']['size'] > 0){
    // run function here
}

If you are checking if a file is correctly uploaded, you should check:

$_FILES['cv']['error'] == UPLOAD_ERR_OK