![]() |
Getting binary data from MySQL to download into a zip
Sorry bout the long name...
Well anyways, now since ive got hte whole displaying an imge thing working, how would i get it so pretty much the same works with a zip file so the person (upon clicking hte link) will get the zip file to download? This is what i have so far and it just gives me a dl.php filled with the binary data lol... PHP Code:
|
Try storing at least the origional file extension on the database.. Then use the octet-stream.
Try something like this: $result=result("SELECT origional_name,extension FROM database WHERE map='$id'"); header("Content-Type: application/octet-stream"); header( "Content-Disposition: attachment; filename=$origional_name.$extension"); exit; |
ok it goes to a zip file now but doesnt have any data in it :-X
|
I'll look into it a bit more when I get home. I've never taken data outa a mysql db for file download.. I'll figure it out..
|
Thanks panther :-D
right now with what you give me, i can get a zip file with the name from the datqabase, but not the data thats in it... |
Code:
<? |
you bloody rock Panther
i changed it just a lil so it would suit me header("Content-Disposition: attachment; // the $name and $data are already called form the database, just recalled the vars here filename=\"$name\".zip"); // .zip for file type header("Content-Length: ".strlen($data)); header("Content-Type: application/octet-stream"); |
1 Attachment(s)
I wrote a script for you in full if you run into a few more errors.. It has a few more explinations like how to do images etc.. Sorry for all the errors above, I wasen't testing anything I was writing.. But glad you got it to work! :). Nice to know someone is trying out there.
you'll have to change some things to test it out / play with it but it's a sample / play script for learning. |
|
gj bro :)
|
All times are GMT -5. The time now is 07:37 PM. |
Powered by vBulletin®