Hi, I've written a short script which creates a rather large object (a PDF file) using FPDF, based on some form input.
At the moment the form page passes on a group of variables to the php file generating the PDF, and the user's browser waits while the server takes its time putting the file together. I would like for the user to be able to enter the desired input in the form (including an e-mail address), and be directed immediately to a page notifying them that when their PDF is complete, a link to it will be mailed to them.
How can I go about achieving this? Are there any open source tools that might help?
I am relatively new to PHP, so any advice on how to minimise server processor usage for such an operation would also be appreciated. Do you think it would be easier to email the file to the user (the files are 2 to 3 MB max)?
Thanks in advance.
Mailing created objects to users
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You could send it as a file attachment if you really wanted to: http://www.swiftmailer.org/docs/tutorials/attachments
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Just looking at the size of the file you're talking about here. The current release may go beyond the 8MB limit since base64 encoding will turn 3MB of data into 4MB and then Swift needs to copy data around etc.EricW wrote:Thanks! I think sending the file itself will be the way to go, rather than setting up temporary directories and pages for each user which have to expire after a set time.
The new version out in (I hesitate to say) about 3 days contains objects which specifically work to lower memory usage by encoding file data on-the-fly. My suggestion (since it's generated by lib pdf) is to dump the data to a tmp file and null it from memory then load that file into a message.
Dealing with large strings is fairly intensive for PHP. You need to really think hard about where you can save memory without a big expense of time/cycles.
Thanks for the thoughtful advice d11.
Would this problem be solved if we went for the direct download route rather than e-mailing the file? I have no definite preference for either (although your library will make the job much simpler), and am trying to find which method would put less load on the server.
Is this something I'll just have to test on my server?
Would this problem be solved if we went for the direct download route rather than e-mailing the file? I have no definite preference for either (although your library will make the job much simpler), and am trying to find which method would put less load on the server.
Is this something I'll just have to test on my server?