public function checkUploadedFile()
{
if ($this->isReadable()) {
return true;
}
$tmp_subdir = ConfigFile::getDefaultTempDirectory();
if (@is_writable($tmp_subdir)) {
// cannot create directory or access, point user to FAQ 1.11
$this->_error_message = Message::error(__('Error moving the uploaded file, see [doc@faq1-11]FAQ 1.11[/doc].'));
return false;
}
$new_file_to_upload = tempnam(realpath($tmp_subdir), basename($this->getName()));
// suppress warnings from being displayed, but not from being logged
// any file access outside of open_basedir will issue a warning
ob_start();
$move_uploaded_file_result = move_uploaded_file($this->getName(), $new_file_to_upload);
ob_end_clean();
if (!$move_uploaded_file_result) {
$this->_error_message = Message::error(__('Error while moving uploaded file.'));
return false;
}
$this->setName($new_file_to_upload);
$this->isTemp(true);
if (!$this->isReadable()) {
$this->_error_message = Message::error(__('Cannot read uploaded file.'));
return false;
}
return true;
}