2

我对以下代码的问题是if(if(empty($fields['Remuse'])))声明其他一切正常。我只把它放在一个 if 语句中,以使警告它是空的现在消失了,当有文件时它不会复制 - 在缓存和数据库中显示很好,为什么?

问题:

  $candidateuploaddir = _MYSITEDIR . '/downloads/refocus_candidates/';
        $candiatefilename = $fields['RenamedResume'];
        $candidatefile = $candidateuploaddir . $candiatefilename;

        if(empty($fields['Remuse']))
        {
                echo 'null';
        }else{
        copy($fields['Resume'],$candiatefilename);
        }

上传功能:

function uploadResume()
{
    if (!isset($_FILES['UploadResume'])) return false;
    $uploaddir = _CACHEDIR.'/resumes/';
    /* create the upload folder if it does not already exist */
    CMS::RecursiveMkdir($uploaddir);
    $extension = CMS::getFileExtension(basename($_FILES['UploadResume']['name']));
    /* keep producing random filenames until we get a unique one */
    while (empty($filename) || CMS::fileExists($uploaddir.$filename)) {
        $filename = CMS::randomString(10).'.'.$extension;
    }

    $uploadfile = $uploaddir . $filename;

    if (move_uploaded_file($_FILES['UploadResume']['tmp_name'], $uploadfile)){

        return $uploadfile;
        //$uploadfile;
    } else {
        return false;
    }
}

在提交线上:

$fields['Resume'] = CMS::either(CMS_Plugin_plugin_jobs_apply::uploadResume(), CMS::getFormData('Resume', false)); //upload resume to temporary location
4

2 回答 2

1

if(if(empty($fields['Remuse'])))还是if(empty($fields['Remuse']))

$fields['Remuse']还是$fields['Resume']


if (empty($fields['Resume']))
{
    echo 'null';
}

else
{
    copy($fields['Resume'],$candiatefilename);
}
于 2012-09-22T02:22:36.850 回答
0

尝试在和/之间添加。$uploaddir$filename

于 2014-10-28T14:52:29.360 回答