function ResourceUpload::upload_error in D7 Media 6
File
- resource/
resource.module, line 428 - Resource API for Drupal, a replacement for files.
Class
Code
function upload_error($errno) {
// If no file was uploaded there is an error. :)
if (empty($_FILES['files']['tmp_name'][$source]) || !is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
return t('No file uploaded');
}
// @see http://php.net/manual/en/features.file-upload.errors.php
switch ($_FILES['files']['error'][$source]) {
case UPLOAD_ERR_OK:
return FALSE;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return t('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array(
'%file' => $source,
'%maxsize' => format_size(file_upload_max_size()),
));
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
return t('The file %file could not be saved, because the upload did not complete.', array(
'%file' => $source,
));
case UPLOAD_ERR_NO_TMP_DIR:
return t('The file %file could not be saved, because the PHP upload_tmp_dir does not exist.', array(
'%file' => $source,
));
case UPLOAD_ERR_CANT_WRITE:
return t('The file %file could not be saved, because the file could not be written to the disk.', array(
'%file' => $source,
));
case UPLOAD_ERR_EXTENSION:
return t('The file %file could not be saved, because the upload was stopped by a php extension.', array(
'%file' => $source,
));
// Unknown error
default:
return t('The file %file could not be saved. An unknown error has occurred.', array(
'%file' => $source,
));
}
}