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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make file and 'save as'

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hello,

I collect some data and want to return this data in a file to the user.
But how can I make that the user gets the 'save as' dialog box when I made the file? I also want that the file is save in the temp directory on my server, not in another directory.

When I use tempnam the script saves a file in c:\windows\temp\. But I can download this file through <a href...>. Also the file is named something like tempD3.tmp. I want to rename this file to something else. Is this possible.

The idea is just to collect data, write it to a file, and the user must get the 'save as' dialog box.

thanks again for you time.

The One And Only KryptoS
 
q: how can I force the save as dialog

you can't - this is browser logic. on most browsers the user gets this choice automatically when you express the content-disposition as attachment and the content-type as an octet-stream.

renaming the file on the local file system

use move_uploaded_file(). choose whatever name you want. you must do this in the script that receives the file though. otherwise php should clean up the temp files as it goes. so you cannot, therefore, use a link to the tempnam file.

but why bother anyway - just bung the temporary file down the tube at the user. use fpassthru or readfile
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top