$filename) { // Check for errors if ($_FILES['bluditInputFiles']['error'][$key] != 0) { $message = 'Error occurred uploading the image, max file size allowed: '.ini_get('upload_max_filesize'); Log::set($message, LOG_TYPE_ERROR); ajaxResponse(1, $message); } // Convert URL characters such as spaces or quotes to characters $filename = urldecode($filename); // Check file extension $fileExtension = pathinfo($filename, PATHINFO_EXTENSION); $fileExtension = Text::lowercase($fileExtension); if (!in_array($fileExtension, $allowedExtensions) ) { $message = 'Extension file not supported.'; Log::set($message, LOG_TYPE_ERROR); ajaxResponse(1, $message); } // Generate the next filename to not overwrite the original file $nextFilename = Filesystem::nextFilename($uploadDirectory, $filename); // Move from temporary directory to uploads folder rename($_FILES['bluditInputFiles']['tmp_name'][$key], $uploadDirectory.$nextFilename); chmod($uploadDirectory.$nextFilename, 0644); // Generate Thumbnail // Exclude generate thumbnail for SVG format and generate a symlink to the svg if ($fileExtension == 'svg') { symlink($uploadDirectory.$nextFilename, $thumbnailDirectory.$nextFilename); } else { $Image = new Image(); $Image->setImage($uploadDirectory.$nextFilename, $site->thumbnailWidth(), $site->thumbnailHeight(), 'crop'); $Image->saveImage($thumbnailDirectory.$nextFilename, $site->thumbnailQuality(), true); } } ajaxResponse(0, 'List of files and number of chunks.', array( 'filename'=>$nextFilename )); ?>