0

I am trying to upload software installation file (.exe) in my site.When I am trying to upload file like 5 mb or 10 mb, I don't get any error.But while trying to upload large file,size of 45/50mb,I am getting this error

(1/1) FatalThrowableError

Call to a member function getClientOriginalExtension() on null

I have changed my php.ini like this:

upload_max_filesize = 900M

Here is my file upload form

<form action="/upload" method="post" enctype="multipart/form-data">
    {{ csrf_field() }}
    Product name:
    <br />
    <input type="text" name="name" />
    <br /><br />
    Files :
    <br />
    <input type="file" name="pdf" multiple />
    <br /><br />
    <input type="submit" value="Upload" />
</form>

Here is my controller:

public function google(Request $request){

            $file = $request->file('pdf');
            $destinationPath = 'uploads';
            $file->move($destinationPath,$file->getClientOriginalName());

}

Update:

I have increased post_max_size greater than upload_max_filesize.But now getting this error

(1/1) FatalErrorException
Allowed memory size of 134217728 bytes exhausted (tried to allocate 62973720 bytes)
in MediaFileUpload.php (line 246)
7
  • Have you changed 'post_max_size' in your php.ini to something higher than the accepted file size? Commented Sep 4, 2017 at 19:50
  • You're not getting the image data. Perform some kind of validation before executing that code. Commented Sep 4, 2017 at 19:51
  • I have changed 'post_max_size' in my php.ini to higher than the accepted file size.Now I am getting this error (1/1) FatalErrorException Allowed memory size of 134217728 bytes exhausted (tried to allocate 62973720 bytes) in MediaFileUpload.php (line 246) Commented Sep 4, 2017 at 20:01
  • 1
    So increase memory as well Commented Sep 4, 2017 at 20:04
  • How can I do that? Commented Sep 4, 2017 at 20:05

2 Answers 2

1

Default php.ini memory_limit is 128 MB. You should either:

  • Optimize your code to use a normal amount of data
  • change memory_limit in php.ini to higher value which I do not recommend at all - with your approach you will hit this wall once again

You should refer to this answer. I would recommend you monitor your application and see if there is a potential memory leak and optimize your code.

One of the key things you need to remember with standard file uploading, is that your server needs to handle the file, hints why it takes up a lot of memory.

Hopefully that helps you on the right path.

Sign up to request clarification or add additional context in comments.

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
Added answer here.
1

In php.ini increase 'memory_limit'

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.