This commit is contained in:
Diego Najar 2021-10-13 21:50:54 +02:00
parent 72d89576f1
commit 594ba12ea3
2 changed files with 8 additions and 1 deletions

View file

@ -566,8 +566,11 @@ function uploadPageFile($pageKey) {
$filename = Filesystem::filename($_FILES['file']['name']);
$absoluteURL = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
$absolutePath = PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
// Move the original file to a page folder
if (Filesystem::mv($_FILES['file']['tmp_name'], $absolutePath)) {
// Create thumbnail if the files is an image
// Change permissions files to rw-r-r
Filesystem::chmod($absolutePath, 0644);
// Create the thumbnails only if the file is an image
$thumbnail = '';
if (in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) {
try {

View file

@ -319,4 +319,8 @@ class Filesystem {
return false;
}
public static function chmod(string $file, int $permissions): bool {
return chmod($file, $permissions);
}
}