When trying to upload an image in Laravel to a web server it is not generating the image. When using the $ request-> hasFile ('image') even though the image is being sent but if I run the same project on the local server it works normally
This is the return of the request on the web server (000webhostapp.com)
Thisisthereturnoftherequestonthelocalserver(Xampp)
On the web server it does not upload the image regardless of the size of the image or the size
I created a function where I upload the image where I pass my request and the object where I want to insert the image:
protected function uploadImage($request, $post){ if ($request->hasFile('imagem')) { $id = $post->id; $image = $request->imagem; if (!is_null($image)){ $file = $image; $extension = $image->getClientOriginalExtension(); $type = 'posts'; $fileName = time() . random_int(100, 999) .'.' . $extension; $destinationPath = public_path('image/'.$type.'/'.$id.'/'); $url = '/image/'.$type.'/'.$id.'/'.$fileName; $fullPath = $destinationPath.$fileName; if (!file_exists($destinationPath)) { File::makeDirectory($destinationPath, 0775); } $image = Image::make($file); $image->save($fullPath, 100); return $url; }else{ return $post->post_midia_url; } } }
I changed the configuration of the filesystems.php file by adding the ftp configuration and also added this to .env