What must be done to make codeigniter force_download to download large files?

Hi Experts!

I'm facing problems when trying to download a 267Mb file by using Codeigniter's force_download.

When downloading smaller files, no problems.
img002
After a long time, the name of the file to be downloaded appears but without the size and after download
it the file has  0KB.

img001
After download:
img_003
The code I used:
      $data = file_get_contents(base_url('arquivos/cesans/e_pub/' . $arquivo));
       force_download($arquivo, $data);

Open in new window


Thanks in advance!
Eduardo FuerteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
You are probably just running out of memory.  The code you show above reads the entire file into memory before it does the force_download.  If you can increase the amount of memory available, you may be able to download larger files.
0
Eduardo FuerteAuthor Commented:
Hello Dave

I did it before...
The directive in PHP.ini I changed was:

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 512M

Open in new window


It was 128M before and causes a memory error.
Maybe it's still insuficient, I'm going to increase it to 1024M


img_001
Am I in the right way?  Another directive must be changed too?

The file has 267M.
0
Dave BaldwinFixer of ProblemsCommented:
That looks ok to me but I never download files that large.  Another thing you may run into is that the script may timeout before the download is done.  267MB takes a while to download.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Eduardo FuerteAuthor Commented:
After tests  1024M make it run OK!
0
Eduardo FuerteAuthor Commented:
In fact is an eBook !  The others are much smaller  treating agro subjects...but this is about the 100 better experimental receipts developed in our experimental kitchen...rsrsrs
0
Loganathan NatarajanLAMP DeveloperCommented:
Also check these variable whether you have set enough memory to process.
max_execution_time & post_max_size
0
Eduardo FuerteAuthor Commented:
Thanks for the assistance!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.