david001
2 weeks ago

code to upload audio

Posted 2 weeks ago by david001

This code given below uploads the image but when i try to upload audio(mp3) it gives me error undefined variable audio


    public function store(Request $request)
    {
        if($request->hasFile('audio')){
            $audio = $request->file('audio')->store('music');
        }
        Music::create([
            'title'=>$request->title,
            'description'=>$request->description,
            
            'audio'=>$audio


        ]);
        return redirect()->back();
    }

Can anybody help to upload audio. Thanks

Please sign in or create an account to participate in this conversation.