<label for="cv"><?php echo JText::_('CV_RESUME'); ?> <span class="fieldreq"><?php echo $req_marker; ?> </span></label> <input class="inputfield" name="cv" id="cv" type="file" /> </div> <div id="fslabel"> <small><?php echo JText::_('COM_JOBBOARD_MIN_PERMFORMATS'); ?> <br /> <span class="right"><?php echo JText::_('COM_JOBBOARD_MAXSIZE') . ' ' . JobBoardGuestHelper::getMaxFileUploadSize() . JText::_('COM_JOBBOARD_MEGABYTES'); ?> </span> </small> </div> </div> <div class="rowsep"> <h4><?php echo JText::_('OPTIONAL'); ?> </h4> <label for="cover_text"><?php echo JText::_('COVER_NOTE'); ?> </label> <br /><small><?php echo JText::_('COVER_NOTE_HINT');
function uploadCv() { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_file.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_guest.php'; $filetypes = JobBoardFileHelper::getMinValidFtypes(); $file_errors = false; $upload_msg = ''; $upload_file = JRequest::getVar('cv', null, 'files', 'array'); //Clean up filename $this->_filename = JFile::makeSafe($upload_file['name']); $this->_filename = str_replace(" ", "_", $this->_filename); // Check valid file format for Upload if ($upload_file["size"] > 0) { if ($upload_file["size"] > JobBoardGuestHelper::getMaxFilesizeBytes()) { $upload_msg = '<li>' . JText::_('MAX_CVSIZE_ERR') . '</li>'; $file_errors = true; } if (!in_array($upload_file['type'], $filetypes)) { $upload_msg .= '<li>' . JText::_('CV_FILEFORMAT_MSG') . '</li>'; $file_errors = true; } } else { if (strlen($this->_filename) <= 0 || $upload_file["size"] <= 0) { $upload_msg = '<li>' . JText::_('CV_FILE_ERR') . '</li>'; $file_errors = true; } } $cv_folder = JPATH_COMPONENT_ADMINISTRATOR . DS . 'cv'; if (!JFolder::exists($cv_folder)) { $upload_msg = '<li>' . JText::_('COM_JOBBOARD_FILE_NOFOLDER') . '</li>'; $file_errors = true; } if ($file_errors) { $corrections = new JObject(); $corrections->errors = true; $corrections->msg = $upload_msg; return $corrections; } $file_hash = strtolower($this->randId()); $hashed_file = strtolower($file_hash . '_' . $this->_filename); //Set up the source and destination of the file $src = $upload_file['tmp_name']; $dest = $cv_folder . DS . $hashed_file; if (!JFile::upload($src, $dest)) { $upload_msg = '<li>' . JText::_('COM_JOBBOARD_FILE_UPLDERR') . ' - ' . $file_name_title . '</li>'; $file_errors = true; } else { unset($upload_file['tmp_name'], $upload_file['error']); //convert to generic MS-Office filetypes if ($upload_file['type'] == $filetypes[3] || $upload_file['type'] == $filetypes[4]) { $upload_file['type'] = "application/msword"; } } if ($file_errors) { $corrections = new JObject(); $corrections->errors = true; $corrections->msg = $upload_msg; return $corrections; } return array(strtolower($this->_filename), $file_hash, $upload_file['type']); }