1

I'm trying upload video in laravel. When it does upload it, it keeping saving file as php3d58.tmp and not mp4. Help me? I've been trying since yesterday and I've got nothing.

1 Answer 1

1

Use the storeAs() method to save uploaded file and getClientOriginalExtension() to get original file extension:

$path = $request->file('video')->storeAs(
    'videos_directory',
    $request->file('video')->getClientOriginalName() . '.' . $request->file('video')->getClientOriginalExtension()
);
Sign up to request clarification or add additional context in comments.

16 Comments

Thanks for responding, But its not working. Can you tell me why its saving as php3d58.tmp and not mp4?
@StephanyRocks what exactly doesn't work? Do you get an error?
Yes something about save as() method. But let me Show you what I have first. This is my code am I doing something wrong?
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Auth; use App\User; class FileController extends Controller { // public function store(Request $request){ $file=$request->file('file'); $filename=time() . '.' .$file->getClientOriginalExtension(); $destinationpath=storage_path('/introvideo',$filename); $file->getPathName(); $file->move($destinationpath); $user=Auth::user(); $user->profilepicture=$file=$filename; $user->save(); } }
@StephanyRocks looks like you literally used $request->file('video'). But it's just an example. Use $request->file('file') instead of $request->file('video').
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.