imagick error handling on upload
This commit is contained in:
parent
f2c1023cc3
commit
9d2df0fc99
|
@ -145,9 +145,12 @@ class FileUploader
|
|||
$this->db->request_upload($this->file_id, $this->file_token, $this->file_extension, $this->timestamp, $this->file_title, $file_preprocessor_data["file_width"], $file_preprocessor_data["file_height"], $file_preprocessor_data["thumbnail_height"]);
|
||||
} catch (ErrorException $ee) {
|
||||
// Reverting steps in order to clean up failed upload
|
||||
if (file_exists($target_name)) unlink($target_name);
|
||||
if (file_exists($target_name)) {
|
||||
unlink($target_name);
|
||||
}
|
||||
|
||||
$this->file_preprocessor->cleanup_upload_error();
|
||||
error("Uploading unsuccessful: " . $ee);
|
||||
error("Uploading file \"" . $this->file_id . "\" did not succeed: \n" . $ee);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,13 @@ class ImagePreprocessor
|
|||
try {
|
||||
$image_path = $GLOBALS["upload_directory"] . $this->file_id . "." . $this->file_extension;
|
||||
$this->thumbnail_height = generate_thumbnail($this->thumbnail_path, $image_path, $this->file["type"]);
|
||||
|
||||
// Rudimentary way to check whether imagemagick works...
|
||||
if (intval($this->thumbnail_height) <= 0) {
|
||||
throw new ErrorException("");
|
||||
}
|
||||
} catch (Exception $err) {
|
||||
throw new ErrorException("Generating image thumbnail did not succeed.");
|
||||
throw new ErrorException("Generating image thumbnail did not succeed. Make sure you set the right path to ImageMagick in the config file.");
|
||||
}
|
||||
|
||||
return array(
|
||||
|
|
Loading…
Reference in New Issue