file upload extensions hot fix

upload script for file types was still looking at mime types instead of
extensions so made that flip so files are sorted properly
This commit is contained in:
ro 2024-03-11 16:42:46 -06:00
parent 6ce5e91624
commit 6a0c583a4f
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50

View file

@ -10,9 +10,7 @@ class FileUploadService
public static function handleFile($request, $type = null) public static function handleFile($request, $type = null)
{ {
//$upload = $request->getUploadedFiles(); //grab uploaded files
//$options = $request->getParsedBody(); //$options = $request->getParsedBody();
//$file = $upload['upload_files'][0];
//front end sends one by one for progress tracking, so grab first //front end sends one by one for progress tracking, so grab first
$file = $request->file('upload_files'); $file = $request->file('upload_files');
$type = $file[0]->extension(); $type = $file[0]->extension();
@ -38,24 +36,22 @@ class FileUploadService
} }
break; break;
case 'video/mp4': case 'mkv':
case 'mp4':
$filesPath = '/assets/video/blog/' . $path . '/'; $filesPath = '/assets/video/blog/' . $path . '/';
break; break;
case 'audio/mpeg': case 'ogg':
case 'mp3':
$filesPath = '/assets/sound/blog/' . $path . '/'; $filesPath = '/assets/sound/blog/' . $path . '/';
break; break;
case 'application/pdf': case 'pdf':
case 'text/plain': case 'txt':
case 'text/rtf': case 'rtf':
$filesPath = '/assets/docs/blog/' . $path . '/'; $filesPath = '/assets/docs/blog/' . $path . '/';
break; break;
} }
//FileUploader::uploadFile('../public' . $filesPath, $file);
$response = [];
try { try {
// if does not exist, so lets create it. // if does not exist, so lets create it.
//var_dump($filesPath);
if (!is_dir($public_path . $filesPath)) { if (!is_dir($public_path . $filesPath)) {
mkdir($public_path . $filesPath, 0755, true); mkdir($public_path . $filesPath, 0755, true);
} }