mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
pkgsubmit.php: Improve file upload error messages
* Currently, $_FILES showing a filesize of zero is interpreted as no file was uploaded, despite other errors potentially being the cause. * The $_FILES superglobal stores what the actual error was, so use it. This includes file write problems, empty uploads, partial uploads, and upload_max_filesize being exceeded. Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
5ebf9d64ee
commit
b5ffdeb63e
1 changed files with 17 additions and 2 deletions
|
@ -28,8 +28,23 @@ if ($uid):
|
||||||
if (isset($_REQUEST['pkgsubmit'])) {
|
if (isset($_REQUEST['pkgsubmit'])) {
|
||||||
|
|
||||||
# Before processing, make sure we even have a file
|
# Before processing, make sure we even have a file
|
||||||
if ($_FILES['pfile']['size'] == 0){
|
switch($_FILES['pfile']['error']) {
|
||||||
$error = __("Error - No file uploaded");
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
|
$maxsize = ini_get('upload_max_filesize');
|
||||||
|
$error = __("Error - Uploaded file larger than maximum allowed size (%s)", $maxsize);
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_PARTIAL:
|
||||||
|
$error = __("Error - File partially uploaded");
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_NO_FILE:
|
||||||
|
$error = __("Error - No file uploaded");
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_NO_TMP_DIR:
|
||||||
|
$error = __("Error - Could not locate temporary upload folder");
|
||||||
|
break;
|
||||||
|
case UPLOAD_ERR_CANT_WRITE:
|
||||||
|
$error = __("Error - File could not be written");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check whether the file is gzip'ed
|
# Check whether the file is gzip'ed
|
||||||
|
|
Loading…
Add table
Reference in a new issue