Fix: create directory if not exist
This commit is contained in:
parent
05679cb4de
commit
d20fdbe6d1
@ -119,6 +119,8 @@ class UploadHandler
|
|||||||
private function create_scaled_image($file_name, $options) {
|
private function create_scaled_image($file_name, $options) {
|
||||||
$file_path = $this->options['upload_dir'].$file_name;
|
$file_path = $this->options['upload_dir'].$file_name;
|
||||||
$new_file_path = $options['upload_dir'].$file_name;
|
$new_file_path = $options['upload_dir'].$file_name;
|
||||||
|
if (create_exdir($options['upload_dir']) >= 0)
|
||||||
|
{
|
||||||
list($img_width, $img_height) = @getimagesize($file_path);
|
list($img_width, $img_height) = @getimagesize($file_path);
|
||||||
if (!$img_width || !$img_height) {
|
if (!$img_width || !$img_height) {
|
||||||
return false;
|
return false;
|
||||||
@ -164,6 +166,11 @@ class UploadHandler
|
|||||||
@imagedestroy($new_img);
|
@imagedestroy($new_img);
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function has_error($uploaded_file, $file, $error) {
|
private function has_error($uploaded_file, $file, $error) {
|
||||||
if ($error) {
|
if ($error) {
|
||||||
@ -202,7 +209,7 @@ class UploadHandler
|
|||||||
$file->size = intval($size);
|
$file->size = intval($size);
|
||||||
$file->type = $type;
|
$file->type = $type;
|
||||||
$error = $this->has_error($uploaded_file, $file, $error);
|
$error = $this->has_error($uploaded_file, $file, $error);
|
||||||
if (!$error && $file->name) {
|
if (!$error && $file->name && create_exdir($this->options['upload_dir']) >= 0) {
|
||||||
if ($file->name[0] === '.') {
|
if ($file->name[0] === '.') {
|
||||||
$file->name = substr($file->name, 1);
|
$file->name = substr($file->name, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user