+ Reply to Thread
Results 1 to 9 of 9

Thread: PHP memory limit problem when creating zip file on fly?

  1. #1
    DaveBC is offline x10Hosting Member DaveBC is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    13

    PHP memory limit problem when creating zip file on fly?

    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

  2. #2
    willemvo's Avatar
    willemvo is offline x10Hosting Member willemvo is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    19

    Re: PHP memory limit problem when creating zip file on fly?

    I have no idea!!

  3. #3
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: PHP memory limit problem when creating zip file on fly?

    Quote Originally Posted by willemvo View Post
    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.
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  4. #4
    DaveBC is offline x10Hosting Member DaveBC is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    13

    Re: PHP memory limit problem when creating zip file on fly?

    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 by DaveBC; 08-17-2008 at 11:43 AM. Reason: Automerged Doublepost

  5. #5
    themasterrocker Guest

    Re: PHP memory limit problem when creating zip file on fly?

    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.

  6. #6
    DaveBC is offline x10Hosting Member DaveBC is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    13

    Re: PHP memory limit problem when creating zip file on fly?

    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

  7. #7
    themasterrocker Guest

    Re: PHP memory limit problem when creating zip file on fly?

    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 themasterrocker; 08-17-2008 at 06:31 PM.

  8. #8
    DaveBC is offline x10Hosting Member DaveBC is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    13

    Re: PHP memory limit problem when creating zip file on fly?

    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

  9. #9
    DaveBC is offline x10Hosting Member DaveBC is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    13

    Re: PHP memory limit problem when creating zip file on fly?

    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

+ Reply to Thread

Similar Threads

  1. Memory Limit Error, Already on php v2
    By 87372 in forum Free Hosting
    Replies: 0
    Last Post: 04-25-2008, 09:36 AM
  2. PHP version + max file size limit
    By tipsyman in forum Free Hosting
    Replies: 3
    Last Post: 02-27-2008, 01:04 PM
  3. php problem
    By himgar in forum Free Hosting
    Replies: 1
    Last Post: 02-22-2008, 02:41 AM
  4. Two very simple php file upload scripts-Free
    By Symbian.Ankit in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 02-20-2008, 09:55 AM
  5. File Size Limit
    By eagleeyed in forum Free Hosting
    Replies: 8
    Last Post: 10-23-2006, 06:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers