Welcome to WebmasterWorld Guest from 23.22.250.113

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

download files from database

php page name

     

brancook

3:16 pm on Nov 7, 2007 (gmt 0)

5+ Year Member



I have some excel files stored in a mysql datatbase that I have displayed in a table. When I click the link to the file and download it, it want's to save the files name as the name of the php page. For instance the link to the file is "fixme.xls" but when I download it and save it to my computer it plugs in "page_name.php" so I have to rename the file to the .xls file name. Is there a way to avoid this?

Habtom

11:38 am on Nov 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have some excel files stored in a mysql datatbase that I have displayed in a table.

I am not going to respond to that specific question, but let you know that you could do this differently if you are not aware of this yet.

Except on very rare cases, it is not recommended to store any kind of file inside a DB. The best way to do is to let the file get stored outside the somewhere in the server and save the file and path in the DB. File is safe, no corruption and no huge sized DBs.

I would recommend you follow this way.

Habtom

joelgreen

11:52 am on Nov 8, 2007 (gmt 0)

5+ Year Member



you should send header with a file name. something like this

$asfname = "desired file name";
header("Content-Disposition: attachment; filename=$asfname");

not sure if it should be enclosed with quotes.

brancook

4:01 am on Nov 9, 2007 (gmt 0)

5+ Year Member



Thanks for the recommendations...

brancook

3:54 am on Nov 10, 2007 (gmt 0)

5+ Year Member



Habtom,

Can you recommend a good tutorial to take a look at for the suggestion that you've made?

brancook

7:01 pm on Nov 17, 2007 (gmt 0)

5+ Year Member



joelgreen,

I actually had what you suggested I just had 'disposition' spelled wrong. Thanks for your help.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month