Fix: Missing error message when files were too large.

This commit is contained in:
Laurent Destailleur 2013-11-23 15:22:27 +01:00
parent 6ffdc039a2
commit 628e8bea83
2 changed files with 53 additions and 14 deletions

View File

@ -321,6 +321,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$result=$object->update($user,0,$nosyncuser,$nosyncuserpass); $result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
if ($result >= 0 && ! count($object->errors)) if ($result >= 0 && ! count($object->errors))
{ {
// Logo/Photo save
$dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos';
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
@ -361,6 +362,19 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$errmsgs[] = "ErrorBadImageFormat"; $errmsgs[] = "ErrorBadImageFormat";
} }
} }
else
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
break;
case 3: //uploaded file was only partially uploaded
$errors[] = "ErrorFilePartiallyUploaded";
break;
}
}
$rowid=$object->id; $rowid=$object->id;
$action=''; $action='';

View File

@ -8,7 +8,6 @@
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2011-2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
@ -280,7 +279,7 @@ if (empty($reshook))
} }
} }
// Gestion du logo de la société // Logo/Photo save
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
@ -311,6 +310,19 @@ if (empty($reshook))
} }
} }
} }
else
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
break;
case 3: //uploaded file was only partially uploaded
$errors[] = "ErrorFilePartiallyUploaded";
break;
}
}
// Gestion du logo de la société // Gestion du logo de la société
} }
else else
@ -354,7 +366,7 @@ if (empty($reshook))
$error = $object->error; $errors = $object->errors; $error = $object->error; $errors = $object->errors;
} }
// Gestion du logo de la société // Logo/Photo save
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
@ -397,6 +409,19 @@ if (empty($reshook))
$errors[] = "ErrorBadImageFormat"; $errors[] = "ErrorBadImageFormat";
} }
} }
else
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
break;
case 3: //uploaded file was only partially uploaded
$errors[] = "ErrorFilePartiallyUploaded";
break;
}
}
// Gestion du logo de la société // Gestion du logo de la société