Support the ongoing development of Laravel.io →
Input Database Forms

I'm trying to save images with Dropzone.js in my Laravel 4 project.

This is my code:

$fileInput = Input::file('file');

    if(Input::hasFile('file'))
    {

        $fileName = Hash::make($fileInput->getClientOriginalName());

        $path = public_path().'/images/';

        $fileType = $fileInput->guessExtension();

        $fileSize = $fileInput->getClientSize()/1024;

        $file           =   new Image;
        $file->nombre   =   $fileName;
        $file->ruta     =   $path;
        $file->tipo     =   $fileType;
        $file->size     =   $fileSize;
        $file->user_id  =   Sentry::getUser()->id;

        if($fileInput->move($path, $fileName.'.'.$fileInput->guessExtension()))
        {
            $file->save();
        }

    }

I'm obtaining the next error message:

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to undefined method Intervention\\Image\\Facades\\Image::save()","file":"\/Applications\/XAMPP\/xamppfiles\/htdocs\/webs\/lara4\/edu1\/app\/controllers\/ImageController.php","line":74}}

So... my problem is that I can't save my image in my Data Base. I save the image in my server, but not in my DB. Any idea why?

Thanks!

Last updated 3 years ago.
0

I guess you should call the 'make' method before you actually try to save the image ...

Last updated 3 years ago.
0

It think it's a naming convention thing. It looks like you set up the Intervention package, and so make the Image Facade in the config/app.php file.

So you call upon a Intervention\Image::save() method which doesn't exists. Rename your Image model to Picture or something or rename the Facade.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

jazuda jazuda Joined 15 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.