Musbah's avatar

why can not upload files in laravel ?

Hey all, in laravel i made form to upload files but can not upload any file except images i want to upload mp4 vedios and another.

if ($request->hasFile('url')) { $fileext=$request->file('url')->getClientOriginalExtension(); $filename=time().'.'.$fileext; $path = $request->file('url')->move(storage_path('app\public\'), $filename); }

0 likes
10 replies
tykus's avatar

Are you getting an error message? Do you exceed the max upload size?

Musbah's avatar

no, it back me to same page , i did't exceed the size

tykus's avatar

it back me to same page

Do you have validation rules specified? Do you display validation errors on the form; you can add this to the form view template temporarily to display any errors coming from the validator:

<pre>@json($errors)</pre>
Musbah's avatar

yes, validation rules specified i uploaded images without errors but mp4 can't

tykus's avatar

Can you share the validation rules?

Did you render the $errors in the view, so you understand if validation errors are causing the issue?

BRVK's avatar

You are saying it is just redirecting back without error.

Please check {{ csrf_field() }} / @csrf is there or not in form.

BRVK's avatar

redirecting back without errors. Strange

are you using request class for validation?

if yes? make this true.

public function authorize() { return true; }

Before this please check form attribute set 'files'=>'true'.

martinbean's avatar

@musbah I imagine if you’re trying to upload MP4 video files then they’re going to be large files, so you’ll be hitting some limits somewhere (whether it be file upload limits or timeout limits).

Instead, you should look into multi-part (chunked) uploading of large files such as videos.

Musbah's avatar

The problem I have is that it does not upload any type of files other than images I have tried uploading photos and it's uploaded without errors.

Please or to participate in this conversation.