Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-12-2004, 07:49 AM
BeBop is offline BeBop
Registered User

Join Date: Jun 2002
Posts: 600

Send a message via ICQ to BeBop Send a message via AIM to BeBop Send a message via Yahoo to BeBop
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:
 $query "SELECT * FROM mapdb_maps WHERE mid='$id'";
    
$result mysql_query($query) or die(mysql_error());

    while(
$row mysql_fetch_array($result)){
    
$data $row['file'];
    
    }
    
    
header("Content-type: application/x-zip");
    echo 
$data
__________________
- My: Drawings, rants, raves, my cat, designs, and everything else i want to put on the net.
Free Teamspeak servers: http://gamersnetwork.us/

Reply With Quote
  #2  
Old 12-12-2004, 10:03 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,964

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;
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 12-13-2004, 05:42 AM
BeBop is offline BeBop
Registered User

Join Date: Jun 2002
Posts: 600

Send a message via ICQ to BeBop Send a message via AIM to BeBop Send a message via Yahoo to BeBop
ok it goes to a zip file now but doesnt have any data in it :-X
__________________
- My: Drawings, rants, raves, my cat, designs, and everything else i want to put on the net.
Free Teamspeak servers: http://gamersnetwork.us/

Reply With Quote
  #4  
Old 12-13-2004, 12:38 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,964

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..
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #5  
Old 12-13-2004, 03:10 PM
BeBop is offline BeBop
Registered User

Join Date: Jun 2002
Posts: 600

Send a message via ICQ to BeBop Send a message via AIM to BeBop Send a message via Yahoo to BeBop
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...
__________________
- My: Drawings, rants, raves, my cat, designs, and everything else i want to put on the net.
Free Teamspeak servers: http://gamersnetwork.us/

Reply With Quote
  #6  
Old 12-13-2004, 05:17 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,964

Code:
<?
$result=result("SELECT * FROM filename,blob FROM table WHERE id='$id'");

header("Content-Disposition: attachment; filename=\"$result[filename]\"");
// or try header("Content-Disposition: inline; filename=\"$result[filename]\"");
header("Content-Length: ".strlen($result[blob]));
header("Content-Type: application/octet-stream"); 

Echo($result[blob]);
?>
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #7  
Old 12-13-2004, 05:46 PM
BeBop is offline BeBop
Registered User

Join Date: Jun 2002
Posts: 600

Send a message via ICQ to BeBop Send a message via AIM to BeBop Send a message via Yahoo to BeBop
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");
__________________
- My: Drawings, rants, raves, my cat, designs, and everything else i want to put on the net.
Free Teamspeak servers: http://gamersnetwork.us/

Reply With Quote
  #8  
Old 12-13-2004, 06:04 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,964

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.
Attached Files
File Type: zip phphq_mysql_blob.zip (1.5 KB, 4 views)
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #9  
Old 12-13-2004, 07:44 PM
BeBop is offline BeBop
Registered User

Join Date: Jun 2002
Posts: 600

Send a message via ICQ to BeBop Send a message via AIM to BeBop Send a message via Yahoo to BeBop
ty i already got it working heheh

http://67.8.147.5/?pg=Map%20Database&cat=1
__________________
- My: Drawings, rants, raves, my cat, designs, and everything else i want to put on the net.
Free Teamspeak servers: http://gamersnetwork.us/

Reply With Quote
  #10  
Old 12-13-2004, 07:47 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,964

gj bro
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any way to zip your maps without buying winzip?????? EMPTY-07 Delta Force 7 03-04-2007 12:47 PM
MIME TYPE for zip files? BeBop Tech Support 5 12-12-2004 10:04 PM
ZIP submission sizes. zza1pqx Feedback / Novahq.net Support 0 09-23-2004 11:18 AM
making a New face .zip Hellfighter Feedback / Novahq.net Support 6 09-10-2003 08:18 PM
Revised SwissImpressions.zip EL_Bastardo UFP Feedback / Novahq.net Support 1 05-25-2002 06:41 AM


All times are GMT -5. The time now is 09:17 AM.




Powered by vBulletin®