Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write file to client

Status
Not open for further replies.

andreas57

Technical User
Joined
Sep 29, 2000
Messages
110
Location
CH
i've got files stored in a mysql database and want offer them for download. how can i let them be downloaded without creating the file on the server? i thought about fsockopen().

andreas owen
aowen@arcade.ch
 
If you're talking about writing the file to your client's system, fsockopen() won't do it. fsockopen() requires that something be listening on a port and IP address.

I recommend that you fetch the data from the database and stream it to the client after setting the appropriate headers for content-type and content-disposition. See the examples on the online manual page under header() for more information:
Want the best answers? Ask the best questions: TANSTAAFL!
 
thanks, that works perfect, but the popup should close after the download. how do i do that? i've seen something with javascript "on_load(close)" or similar but i couldn't get it to work

andreas owen
aowen@swissonline.ch
 
He is probaly talking about the download window that appears once he streams the appropriate header.
 
well to stream the download i have to open a popup and declair the headers. afterwards the stystem-window comes and prompts where to save the download. after the download the popup is still there. is there a way to do this without popup?

andreas owen
aowen@swissonline.ch
 
write

<script language=javascript>
self.close
</script>

to the window after the code to send the headers? Might need a ; on the end of that line, been years since I used javascript.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top