|
@@ -88,6 +88,41 @@ class Photo extends Module {
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
|
|
+ # Check if file exceeds the upload_max_filesize directive
|
|
|
+ if ($file['error']===UPLOAD_ERR_INI_SIZE) {
|
|
|
+ Log::error($this->database, __METHOD__, __LINE__, 'The uploaded file exceeds the upload_max_filesize directive in php.ini');
|
|
|
+ if ($returnOnError===true) return false;
|
|
|
+ exit('Error: The uploaded file exceeds the upload_max_filesize directive in php.ini!');
|
|
|
+ }
|
|
|
+
|
|
|
+ # Check if file was only partially uploaded
|
|
|
+ if ($file['error']===UPLOAD_ERR_PARTIAL) {
|
|
|
+ Log::error($this->database, __METHOD__, __LINE__, 'The uploaded file was only partially uploaded');
|
|
|
+ if ($returnOnError===true) return false;
|
|
|
+ exit('Error: The uploaded file was only partially uploaded!');
|
|
|
+ }
|
|
|
+
|
|
|
+ # Check if writing file to disk failed
|
|
|
+ if ($file['error']===UPLOAD_ERR_CANT_WRITE) {
|
|
|
+ Log::error($this->database, __METHOD__, __LINE__, 'Failed to write photo to disk');
|
|
|
+ if ($returnOnError===true) return false;
|
|
|
+ exit('Error: Failed to write photo to disk!');
|
|
|
+ }
|
|
|
+
|
|
|
+ # Check if a extension stopped the file upload
|
|
|
+ if ($file['error']===UPLOAD_ERR_EXTENSION) {
|
|
|
+ Log::error($this->database, __METHOD__, __LINE__, 'A PHP extension stopped the file upload');
|
|
|
+ if ($returnOnError===true) return false;
|
|
|
+ exit('Error: A PHP extension stopped the file upload!');
|
|
|
+ }
|
|
|
+
|
|
|
+ # Check if the upload was successful
|
|
|
+ if ($file['error']!==UPLOAD_ERR_OK) {
|
|
|
+ Log::error($this->database, __METHOD__, __LINE__, 'Upload contains an error (' . $file['error'] . ')');
|
|
|
+ if ($returnOnError===true) return false;
|
|
|
+ exit('Error: Upload failed!');
|
|
|
+ }
|
|
|
+
|
|
|
# Verify extension
|
|
|
$extension = getExtension($file['name']);
|
|
|
if (!in_array(strtolower($extension), Photo::$validExtensions, true)) {
|