为什么我在复制文件时会出现权限错误?
我有print_r
, $candidatefile
这显示了新位置的完整文件路径和正确名称。
$fields['Resume']
运行时为空白,print_r
但文件仍上传到缓存
两个文件夹都是777
/home/name/mysite0912/cache/resumes/1ZHiYGZj7J.txt Remuse /home/name/mysite0912/downloads/cv_folder/new-filename-cv.txt 新位置
其他的都很甜,除了
代码部分:
$candidateuploaddir = _MYSITEDIR . '/downloads/refocus_candidates/';
$candiatefilename = $fields['RenamedResume'];
$candidatefile = $candidateuploaddir . $candiatefilename;
if(empty($fields['Resume']))
{
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