2

I am developing a photo gallery and having the problem that I get following error message after trying to upload images which are far bigger (70mb) than those which are working (5-10mb). Error Message: stream_copy_to_stream(): Read of 8192 bytes failed with errno=21 Is a directory

I also changed inside the php.ini file the max upload size to over 1000m but I am getting still the same error message.

Do you have any idea why I am getting the error message?

1
  • This error doesn't look like an issue from the upload itself but more an issue of what you're doing with the file after Commented Jan 1, 2022 at 22:49

2 Answers 2

2

This is related to the PHP settings. The error is not clear in this case, but likely you just need to increase these variables on your PHP.ini file:

  • upload_max_filesize
  • post_max_size memory_limit
Sign up to request clarification or add additional context in comments.

2 Comments

where is the php.ini file located for laravel?
The php.ini file isn't laravel specific, it's part of your web hosting platform. If you create a simple phpinfo() page, it will tell you where the ini files are located.
0

I also think that it's a php settings related issue.
You can temporarily change the php.ini configuration directly in your method like below.

public function upload()
{
    ini_set('memory_limit','2024M');
    ini_set('post_max_size','2024M');
    ini_set('upload_max_filesize','2024M');
    ini_set('max_input_time', 36000); // 10 houres
    set_time_limit(36000); // 10 houres

    // your image upload related logic
}

Instead of changing the php.ini file, you can alter the settings only for certain routes. You can define the custom settings directly in you controller method like above, Or you can set it in the constructor of that controller.

Comments

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.