1

Hi I am trying to integrate Dropzone.js in my app and using Laravel Framework. I have a form with below code,

<form method="post" action="{{url('/example/fileupload')}}" 
enctype="multipart/form-data" class="dropzone" id="my-awesome-dropzone">

    @csrf


<input type="submit">

</form>

The laravel controller attached with this form has below code in which I am just trying to get the name if the image which is dropped in dropzone area,

   public function fileupload(Request $request)
    {


 $file = $request->file('file');


$filename = $file->getClientOriginalName();
echo $filename;

}

After clicking submit button it shows me below error,

Call to a member function getClientOriginalName() on null

Dont know what I am doing wrong here, because when I try to run the same code with simple

<input type="file" name="file"> 

it shows me the name of the uploaded image file which I want. Any suggestion or fix? Thanks

1 Answer 1

0

Try changing the "Input" class for "Request" ... I believe it will work. The error is being reported because there is no method on the object you are calling.

public function fileupload(Request $request)
    {
        $file= $request->file('file');
        $fileName = $image->getClientOriginalName();
        echo $fileName;
    }
Sign up to request clarification or add additional context in comments.

2 Comments

Bartollo thanks for your reply. but still the same error. I also edited my question with your suggestion.
@DarazPk see that article appdividend.com/2018/05/31/…

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.