Zubair Mukhtar
Zubair Mukhtar

Reputation: 320

when i upload mp3 file but not sending with same name and using laravel

I am trying to upload an mp3 file but mp3 file sending is successfully sending but unfortunately not sending with the same name and extension
currently sending in database BM4T8rZbRAOYTEFRyuHec9Bz7jf8woFnzpJhRqug.mpga but i want like this para.mp3

controller

 */
    public function store(Request $request)
    {
        
        $request->validate([
            'para_name' => 'required',
            'audio_file' => 'required'
        ]);                
        
        $alQuran = new AlQuran;

        if($request->audio_file)
        {
            Storage::disk('audiofile')->delete($alQuran->audio_file);

            $alQuran->audio_file = Storage::disk('audiofile')->putFile('',$request->audio_file);
        }

        $alQuran->para_name = $request->para_name;  
        $alQuran->type = 1;
        $alQuran->save();

        return redirect()->route('alquran');
    }

Upvotes: 1

Views: 76

Answers (1)

tawfik al
tawfik al

Reputation: 34

you can try to put name of file in the first parameter of function putFile like this

  $alQuran->audio_file = Storage::disk('audiofile')->putFile('para.mp3',$request->audio_file);

Upvotes: 1

Related Questions