我对以下代码的问题是if(if(empty($fields['Remuse'])))
语句其他一切正常。我只把它放在一个if语句中来发出警告它是空的现在它不会在有文件时复制 - 显示在缓存和db中为什么这么好?
问题:
$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
答案 0 :(得分: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);
}
答案 1 :(得分:0)
尝试在/
和$uploaddir
之间添加$filename
。