Php – Laravel-fopen: failed to open stream: Permission denied

laravelPHP

I'm trying to upload an image to laravel's /storage directory. I'm getting an error

fopen(C:\Temp\AppName\public): failed to open stream: Permission denied

This is the code i'm using to upload the image

 public  function SaveImage($image){       
    $fileName = time() . '.' . $image->getClientOriginalExtension();
    $path =$image->storeAs('images/users', $fileName);
    return $fileName;
}

I have given the permission for IUSR and IIS_USER, so I don't understand how it is a permission error.
Image uploading works perfectly fine on window 10(IIS 10) and fails on window 7(IIS 7) with permission denied.

Im using laravel 5.7 and php 7.2.11.

Any help is appreciated, Thank you.

Best Answer

I had this problem too. Make sure that you change your php.ini file to

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

Explanation: The default setting for the php.ini file is

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

That's why you can't upload images larger than 2 MB.

Regards