Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cheasamnang's avatar

Laravel 5 Image Upload and Resize.

I have problem with upload image and resize.

I cannot use Image::make();

0 likes
22 replies
fraserk's avatar

Hard to help with no error message or code. What error are you getting?

3 likes
SCC's avatar
Image::make();

Assumes you have properly installed intervention first of all, after that as @fraserk has said, not enough information.

samsoft's avatar

Can i use Intervention with Laravel 5? can you prompt me its github? currently having issue uploading file to server

abhishek009's avatar

yeah ! I'm using it on L-5.

https://github.com/Intervention/image

Example code :

 if(Input::file())
        {
  
            $image = Input::file('image');
            $filename  = time() . '.' . $image->getClientOriginalExtension();

            $path = public_path('profilepics/' . $filename);
 
        
                Image::make($image->getRealPath())->resize(200, 200)->save($path);
                $user->image = $filename;
                $user->save();
           }

It will upload an Image in public/profilepics folder.

9 likes
samsoft's avatar

@LeeW i was trying to use $file = $request->file('photo'); before but return null, any reason for that.. i've included enctype="multipart/form-data" in my form

SCC's avatar

I suspect you are wanting to check if the file exist and then do something with it, so something like.

if (Request::hasFile('photo'))
{
$file = Request::file('photo');
    //and do this
}
samsoft's avatar

@LeeW i received error messsage while installing intervention, any help

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for intervention/image 2.2.0 -> satisfiable by interv
ention/image[2.2.0].
    - intervention/image 2.2.0 requires ext-fileinfo * -> the requested PHP exte
nsion fileinfo is missing from your system.

Sonu's avatar

@cheasamnang use it

        $file = Request::file('file');
        $image_name = time()."-".$file->getClientOriginalName();
        $file->move('uploads', $image_name);
        $image = Image::make(sprintf('uploads/%s', $image_name))->resize(200, 200)->save();
1 like
SCC's avatar
requires ext-fileinfo

@samsoft This is missing from your server, you will need to install it.

abhishek009's avatar

Go to the php.ini file uncomment this line.

extension=php_fileinfo.dll
Sonu's avatar
In php.ini
extension=php_fileinfo.dll
SCC's avatar

Unchecking it is not the issue, like I say, it's missing from your system, i.e not installed. The clue is in the error message

requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.

Make sure you check all of php.ini for references to extension=php_fileinfo.dll and then restart apache or NGiNX, whatever you are using.

samsoft's avatar

I've restart the apache web server after editing php.ini file. i'm using xampp... is there any php file apart from the one inside xampp folder? i type

which php --> /c/Program Files (x86)/iis express/PHP/v5.6/php

samsoft's avatar

Waooo... it finally work, i was editing a wrong php.ini file... after typing "which php" and gave me the path to php i was using,

which php --> /c/Program Files (x86)/iis express/PHP/v5.6/php

Then i edit the php.ini inside the php folder. Thanks for your support guyz... i appreciate

1 like
sorcjc's avatar

Hi. If I just need to upload an image (without resize), can I use only the Storage class?

Rahmanrezaee's avatar

if you are new programmer mybe not import the Image class used phpstorm ida its auto add namespace

Please or to participate in this conversation.