forked from projects/fipamo
07b422a9c3
This one is a doozy, so let's breakt it down into what areas where touched. - updated package json to remove unneeded dependencies. - rebuilt file uploading to simply a very convuluted process - began proces to replace icons with https://tabler-icons.io - began process of removing the need for css preprocessor and using pure css - login completed - dashboard index completed - page edit ui completed - page edit ui text editor tweaked so syntax highlighting is cleaner and more accurate The settings and navigation UIs still remain and then polishing the responsive for the new css structure
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace brain\api\v1;
|
|
|
|
use brain\utility\FileUploader;
|
|
|
|
class FilesAPI
|
|
{
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
public static function uploadFiles($request, $type = null)
|
|
{
|
|
$upload = $request->getUploadedFiles(); //grab uploaded files
|
|
$file = $upload['upload_files'][0]; //front end sends one by one for progress tracking, so grab first
|
|
$type = $file->getClientMediaType();
|
|
$filesPath = '';
|
|
$path = date('Y') . '/' . date('m');
|
|
$response = [];
|
|
switch ($type) {
|
|
case 'image/jpeg':
|
|
case 'image/png':
|
|
case 'image/gif':
|
|
case 'image/svg':
|
|
$filesPath = '/assets/images/blog/' . $path . '/';
|
|
|
|
break;
|
|
case 'video/mp4':
|
|
$filesPath = '/assets/video/blog/' . $path . '/';
|
|
break;
|
|
case 'audio/mpeg':
|
|
$filesPath = '/assets/sound/blog/' . $path . '/';
|
|
break;
|
|
case 'application/pdf':
|
|
case 'text/plain':
|
|
case 'text/rtf':
|
|
$filesPath = '/assets/docs/blog/' . $path . '/';
|
|
break;
|
|
}
|
|
|
|
FileUploader::uploadFile('../public' . $filesPath, $file);
|
|
|
|
$response = [
|
|
'message' => "File Uploaded. Great!",
|
|
"filePath" => $filesPath . urlencode($file->getClientFileName()),
|
|
"fileName" => urlencode($file->getClientFileName()),
|
|
'type' => $type,
|
|
];
|
|
|
|
return $response;
|
|
}
|
|
}
|