Track file upload errors in PHP

10 Mar

$upload_errors = array(

UPLOAD_ERR_OK                 => "No errors.",
UPLOAD_ERR_INI_SIZE              => "Larger than upload_max_filesize.",
UPLOAD_ERR_FORM_SIZE             => "Larger than form MAX_FILE_SIZE.",
UPLOAD_ERR_PARTIAL             => "Partial upload.",
UPLOAD_ERR_NO_FILE             => "No file.",
UPLOAD_ERR_NO_TMP_DIR         => "No temporary directory.",
UPLOAD_ERR_CANT_WRITE         => "Can't write to disk.",
UPLOAD_ERR_EXTENSION             => "File upload stopped by extension."
$error = $_FILES['file_upload']['error'];
$message = $upload_errors[$error];
echo $message;

Leave a comment

Posted by on March 10, 2012 in PHP



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: