PHP5 Universal File Download Class
Written by Chris on August 12, 2008 – 12:16 pm -After finding different hosting companies having wildly different policies when it comes to what's enabled and what isn't in PHP, I've built a generic file download class which should work in almost all situations.
This is the first version so there are some improvements to be made and if you download it, you'll see where some improvements may be made. I will be releasing another version when I've had time to do some further work on it. For now you can find the source code plus any community improvements here: http://www.refactormycode.com/codes/440-universal-file-download-class
I should also mention that this class has been cleaned of some application specific code, so if there's any disjointed bits I apologise - I have tried to deal with any discontinuities before posting but there may be something i've missed (this is also the reason for the bunch of if's in get_file() if you are to use this as is you may want to replace them with your own custom code).
Popularity: 87% [?]
Sphere: Related ContentRelated posts on coderchris.com:
- Simple Function To Force Download Of A File
The following function will allow you to run a file download through PHP, you could... - Refactor My Code - I Wish I’d Thought of It!
refactormycode.com is a fledgling website setup as a project by French Canadian Ruby Developer Marc-André... - Why @ is NOT your friend
Ah, the error suppression operator (@) It seems like such a fantastic idea, just put... - File-system mp3 Organisation - Is It Really That Hard?
Like most people I know I have a lot of mp3's and every person likes... - Funky ORM with PHPDoctrine
I work on all sorts of little personal projects in my spare time, most of...
Tags: 5, Class, Download, file, PHP, script, Universal
Posted in PHP, Web Development | Trackback |














Feed 

August 19th, 2008 at 12:47 pm
Universal File Download Class…
I wish I had this last night… gah!…
August 19th, 2008 at 7:41 pm
Universal File Download Class…
In your function ‘public function cc_wget_file($url)’, you’re passing the string through exec(). Thats fine, but PHP allows you to pass cli strings via backticks (http://www.php.net/language.operators.execution). Might help, might not, ymmv….
August 20th, 2008 at 5:21 pm
Universal File Download Class…
@Ishkur
I try to avoid back-ticks as (for me at least) they obfuscate the code a little bit.
That said, it may give a small performance boost - I don’t know as I’ve not done any such tests, but maybe I will if I get 5 mins :)…