Saturday, March 10, 2012

Track file upload errors in PHP

[sourcecode language="php"]
<?php
if(isset($_POST['btn_upload']))
{

$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;
}
?>

[/sourcecode]

No comments:

Post a Comment

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...