jeudi 8 juin 2017

laravel dropzone getRealPath

I have a problem implementing uploading logo using dropzone, I have a form like this:

<div id="image1" class="image-gallery">
                <img class="images" src="#" />
                <form style="width: 100%; height:100%;" action="" class="dropzone" id="my-awesome-dropzone">
                <input type="hidden" name="_token" value="">
            </form>
                </div>

Controller:

    public function gallery() {
        $image = Input::file('image');
        $destinationPath = 'gallery';
        $filename = str_random(12);
        // $filename  = time() . '.' . $image->getClientOriginalExtension();
        $path = public_path('gallery/' . $filename);
        Image::make($image->getRealPath())->fit(303, 200)->save($path);
}

and route:

Route::post('test2', 'BusinessController@gallery');

However I get error message:

Call to a member function getRealPath() on null

If I try:

$image = Input::hasFile('image');

I get:

Call to a member function getRealPath() on boolean

How can I fix this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire