PHP memory limit problem when creating zip file on fly?

DaveBC

New Member
Messages
13
Reaction score
0
Points
0
Hi there,

I'm building a site for my band that lets people download mp3s of our songs if (and only if) they've signed up to our mailing list.

To download the mp3s, the user ticks check boxes in a form which is submitted to a PHP script that uses the class of someone brighter than me (the script that calls the class is a modified version of this) to generate a .zip file on the fly, containing the mp3s.

It works brilliantly so long as I only select a few mp3s at a time, but say i were to select all of them, the browser would display an error page with the message:

'Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13475625 bytes) in /home/dwmarrs/public_html/theblitzcartel/createZip.php on line 110'

The total size of the mp3s is 17.8MB. Do you think this problem would sort itself out if i applied for intermediate or advanced PHP configuration, with their greater memory limits? Or am i going to have to come up with some javascript so that the user can only tick a few boxes at a time?

Any guidance that anyone can offer on this would be much appreciated.

Thanks very much,

David
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
I have no idea!!
This is basicly spam...

Ontopic:
I'm not sure about the memory limits, but it might be a good idea to limit the amount of bytes the user can download. This does not require JavaScript, but it can be done serverside.
I'm thinking you can give a maximum of (for example) 10 mb limit, so you just process the list of selected files, each time checking the file size. If the size exceeds 10 mb, generate an error to make the user select fewer files, if the size is less than 10 mb, continue with the script.

Just a basic idea, but it might not be the best way to solve things.
 

DaveBC

New Member
Messages
13
Reaction score
0
Points
0
I was thinking i might have to do that, it's just more work for me... :ugh:

And a bit less user friendly. But then they are getting these mp3s for free!

I think the problem is that the script I'm using has to read all the mp3s and then write them into a temporary .zip file (a download of which is then forced upon the user). So that's 17.8MB of memory times 2, which is greater than 33554432 bytes?

But, as I said, I don't really understand it and that's why I'm using Rochak Chauhan's class! Maybe I should experiment with how many mp3s (how big a total filesize) I can get it to currently work with...
Edit:
Weird, it appears to have sorted itself out; I can now download a zip file containing all the mp3s at once!

If someone read my posts and sorted out my account, thank you very, very much!

David
 
Last edited:
T

themasterrocker

Guest
Woiwky was doing the files and things for you. When i was talking to him on msn last night he was anyway >.> i don't know if he's finished them.
 

DaveBC

New Member
Messages
13
Reaction score
0
Points
0
Well, my thanks to Woiwky then!

Except... he couldn't turn my mail() function back on could he? It seems to have stopped working, which is making the mailing list part of the plan a bit tricky.

Wasn't quite sure why I still had it in the first place as I seem to be on the basic PHP configuration. Figured it was because I registered before the changes were made to the configuration of PHP on the servers (I've spent several months on and off just getting my head around PHP and testing pages without going live with any sites). Still, I wasn't going to complain about such a thing!

Thanks,

David
 
T

themasterrocker

Guest
Lol, i've asked him to make something up for me and he said i'm working on this memory limit and i went whats this memory limit? and he sent me the URL to this. So you just need to wait for him to post it :p Although he was "due" to have it done last night
 
Last edited by a moderator:

DaveBC

New Member
Messages
13
Reaction score
0
Points
0
Hi there,

I'm still without mail() function. Should I just put in a request to be moved onto the Intermediate PHP configuration through the Account Management Panel? Would that be the easiest way to get it back?

Thanks,

David
 

DaveBC

New Member
Messages
13
Reaction score
0
Points
0
Hi again,

So I applied for Intermediate PHP and was approved and now I have mail() back! Unfortunately I guess moving it onto this configuration undid whatever Woiwky did, because now when I try and download all the mp3s in a zip file I get the error message:

'Fatal error: Allowed memory size of 50331648 bytes exhausted (tried to allocate 18217013 bytes) in /home/dwmarrs/public_html/theblitzcartel/createZip.php on line 149'

(notice they're different figures this time)

Woiwky, if you're reading this, could you please please please fix my memory limits again?

Thanks very much,

David
 
Top