Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit b9f6524

Browse files
committed
Added file permissions problem detection
1 parent 093ec8d commit b9f6524

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

server/php/UploadHandler.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class UploadHandler
3434
'min_width' => 'Image requires a minimum width',
3535
'max_height' => 'Image exceeds maximum height',
3636
'min_height' => 'Image requires a minimum height',
37+
'up_dir_make' => 'The web server does not have permission to create the upload directory',
38+
'up_dir_write' => 'The web server does not have upload dir file save permission',
3739
'abort' => 'File upload aborted',
3840
'image_resize' => 'Failed to resize image'
3941
);
@@ -1064,7 +1066,16 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
10641066
$this->handle_form_data($file, $index);
10651067
$upload_dir = $this->get_upload_path();
10661068
if (!is_dir($upload_dir)) {
1067-
mkdir($upload_dir, $this->options['mkdir_mode'], true);
1069+
if (!mkdir($upload_dir, $this->options['mkdir_mode'], true)) {
1070+
unlink($uploaded_file);
1071+
$file->error = $this->get_error_message('up_dir_make');
1072+
return $file;
1073+
}
1074+
}
1075+
if (!is_writable($upload_dir)) {
1076+
unlink($uploaded_file);
1077+
$file->error = $this->get_error_message('up_dir_write');
1078+
return $file;
10681079
}
10691080
$file_path = $this->get_upload_path($file->name);
10701081
$append_file = $content_range && is_file($file_path) &&

0 commit comments

Comments
 (0)