Why am I getting a permission error on the line were I copy the file across?
I have print_r on $candidatefile and this shows the full file path and correct name to the new location.
$fields['Resume'] is blank when I run print_r but the file still uploads to the cache
both folders are 777
/home/name/mysite0912/cache/resumes/1ZHiYGZj7J.txt Remuse
/home/name/mysite0912/downloads/cv_folder/new-filename-cv.txt New Location
Everything else is sweet except that
Code Section:
$candidateuploaddir = _MYSITEDIR . '/downloads/refocus_candidates/';
$candiatefilename = $fields['RenamedResume'];
$candidatefile = $candidateuploaddir . $candiatefilename;
if(empty($fields['Resume']))
{
echo 'null';
}else{
copy($fields['Resume'],$candiatefilename);
}
Upload Function:
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;
}
}
On Submit Line:
$fields['Resume'] = CMS::either(CMS_Plugin_plugin_jobs_apply::uploadResume(), CMS::getFormData('Resume', false)); //upload resume to temporary location
So us a print_r of ($_FILES); have you set the enctype of the form to allow files uploads ?
before this line, add: