Welcome Guest, Not a member yet? Register   Sign In
Impossible Force Download
#1

[eluser]deltajam[/eluser]
Ugh. I am frustrated. I do not know much about headers, and php streaming ... and the like, so I'm possibly ignorantly frustrated.

Here is my code:

Code:
$data = file_get_contents( base_url() . "media/downloads/movie.mov");
        
$name = 'myphoto.jpg';

force_download($name, $data);

The file is 40mb, and I have some that are in excess of 150mb. At first I was getting a blank page, which was caused by a leading slash in my url. After that change, I get this error:

Code:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes)

Does anyone have any suggestions for an average hack like me? My hosting is with iPower (equally frustrating).
#2

[eluser]Christopher Blankenship[/eluser]
correct me if i am wrong but the error looks like more a size limit issue with php.ini regarding memory_limit if i recall. post_max_size would be the other item to look at if you were attempting to upload those files through a form submission.
#3

[eluser]deltajam[/eluser]
This is true, however I would like to stream the file to the user ... not have them wait 20mins with a blank screen, and then the download is finished. I've also been following this thread with no luck:

http://ellislab.com/forums/viewthread/71192/P0/

Is it really possible the max_size option in php.ini is my only problem? Will this solution bottleneck eventually with many simultaneous downloads?
#4

[eluser]deltajam[/eluser]
anyone? I changed the memory limit in php.ini to:

Code:
memory_limit = 120M

I still get this error:

Code:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes)


ugh.
#5

[eluser]johnwbaxter[/eluser]
Have you rebooted apache? You might need to to pick up changed php.ini values, also that may not be the correct php.ini you have changed, do a phpinfo() to find out the file location of the one you need to amend.
#6

[eluser]deltajam[/eluser]
After making some calls, I think I got it working. But I'm worried (again, possibly due to ignorance) about 100 users all downloading a 50mb file at once. Will they get the same error as before?
#7

[eluser]Mike Ryan[/eluser]
[quote author="deltajam" date="1224727338"]
Code:
$data = file_get_contents( base_url() . "media/downloads/movie.mov");
        
$name = 'myphoto.jpg';

force_download($name, $data);
[/quote]

The file name has a jpg extension, but the file is a .mov. I assume from the size that it is a movie file, and not an image. If that is the case, have you considered streaming the video using a flash video player, a la YouTube? This would handle the streaming, and you can provide a link to download the file separately.

Quote:After making some calls, I think I got it working. But I'm worried (again, possibly due to ignorance) about 100 users all downloading a 50mb file at once. Will they get the same error as before?

No, the memory limit is per script, i.e. each has an allocation of 120M. Although your server will probably be crawling by this point, unless you have 7GB+ RAM ;-)
#8

[eluser]deltajam[/eluser]
[quote author="Mike Ryan" date="1224804565"][quote author="deltajam" date="1224727338"]
Code:
$data = file_get_contents( base_url() . "media/downloads/movie.mov");
        
$name = 'myphoto.jpg';

force_download($name, $data);
[/quote]

The file name has a jpg extension, but the file is a .mov. I assume from the size that it is a movie file, and not an image. If that is the case, have you considered streaming the video using a flash video player, a la YouTube? This would handle the streaming, and you can provide a link to download the file separately.

Quote:After making some calls, I think I got it working. But I'm worried (again, possibly due to ignorance) about 100 users all downloading a 50mb file at once. Will they get the same error as before?

No, the memory limit is per script, i.e. each has an allocation of 120M. Although your server will probably be crawling by this point, unless you have 7GB+ RAM ;-)[/quote]

My site is a download site for videos. You are able to preview the video with a Flash Video player, but we are talking about downloading large video files here.

I'm not sure how much RAM the server has, I can imagine that my client would enjoy a dedicated server if RAM becomes an issue.
#9

[eluser]Christopher Blankenship[/eluser]
For that matter you could utilize: JW FLV Player. I used this one to build a youtube-type site. It handles a lot of different file formats and can be set to autostart in the player. I also found this one but have never used it VLC.

But he is wanting to force download the file. The only recommendation due to the file sizes would be to not utilize a shared hosting environment because they may cancel your account if you greatly effect other customers on the server. Dedicated Hosting would probably be a better fit because even a Virtual Private Server could have issues with large file types, still being in a shared system but with a lot fewer sites, but there you are still only getting a slice of the machine other than that you would have to build, config, and host your own server and that in itself can be costly and time consuming. But you may need to research some host's VPS and Dedicated Hosting accounts to find what will work for you.
#10

[eluser]deltajam[/eluser]
Thank you very much for your detailed reply weremax.




Theme © iAndrew 2016 - Forum software by © MyBB