nafeeur10's avatar

How to upload json file and Extract in Laravel 7

Hello,

I want to upload a json file and Extract it in Controller and keep the data in Database. What will be the approach?

File Upload Controller:

public function fileUploadPost(Request $request)
    {
 
        dd($request);

        $request->validate([
            'file' => 'required|mimes:pdf,xlx,csv,json|max:2048',
        ]);
  
        $fileName = time().'.'.$request->file->extension();  
   
        $request->file->move(public_path('uploads'), $fileName);
   
        return back()
            ->with('success','You have successfully upload file.')
            ->with('file',$fileName);
   
    }

File is not uploading!!!

dd() is giving me this output:

https://ibb.co/55cd2Xb

0 likes
1 reply
a4ashraf's avatar

@nafeeur10

check your form HTML in the Blade file. it should be this

enctype="multipart/form-data"

and 2nd point may be an issue in this path public_path('uploads'),

run this command following

php artisan storage:link

Please or to participate in this conversation.