In my local environment why I do following, it works.
if( $request->file ){
$path = $request->file('file')->store('public/chat/files');
$mime_type = $request->file('file')->getMimeType();
if( strstr( $mime_type, 'video' ) ){
$data['message_type'] = 'video';
}else if( strstr( $mime_type, 'image' ) ){
$data['message_type'] = 'image';
}else if( strstr( $mime_type, 'audio' ) ){
$data['message_type'] = 'audio';
}
But on apache running on Digital Ocean droplet when I run the same code I get the following error.
[2019-02-26 11:45:48] local.ERROR: The file "" does not exist {"userId":3,"email":"user@user.com","exception":"[object] (Symfony\\Component\\HttpFoundation\\File\\Exception\\FileNotFoundException(code: 0):
The file \"\" does not exist a$
[stacktrace]
#0 /var/www/html/plugin_love_api/vendor/symfony/http-foundation/File/File.php(79): Symfony\\Component\\HttpFoundation\\File\\MimeType\\MimeTypeGuesser->guess('')
#1 /var/www/html/plugin_love_api/vendor/symfony/http-foundation/File/File.php(58): Symfony\\Component\\HttpFoundation\\File\\File->getMimeType()
#2 /var/www/html/plugin_love_api/vendor/laravel/framework/src/Illuminate/Http/FileHelpers.php(60): Symfony\\Component\\HttpFoundation\\File\\File->guessExtension()
#3 /var/www/html/plugin_love_api/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php(35): Illuminate\\Http\\UploadedFile->hashName()
#4 /var/www/html/plugin_love_api/app/Http/Controllers/ChatController.php(71): Illuminate\\Http\\UploadedFile->store('public/chat/fil...')
#5 [internal function]: App\\Http\\Controllers\\ChatController->sendMessage(Object(Illuminate\\Http\\Request))
#6 /var/www/html/plugin_love_api/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#7 /var/www/html/plugin_love_api/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('sendMessage', Array)
#8 /var/www/html/plugin_love_api/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\ChatController), 'se$
#9 /var/www/html/plugin_love_api/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#10
PHP version is : PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb 8 2019 14:54:22) ( NTS )
Also I have set 777 permissions on storage
folder and all it's descendants.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire