Welcome to WebmasterWorld Guest from 54.147.134.218

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

download files from database

php page name

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

Junior Member

5+ Year Member

joined:Oct 2, 2006
posts:187
votes: 0


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?
11:38 am on Nov 8, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 15, 2004
posts:1867
votes: 0


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

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

Preferred Member

5+ Year Member

joined:July 31, 2006
posts:629
votes: 0


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.

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

Junior Member

5+ Year Member

joined:Oct 2, 2006
posts:187
votes: 0


Thanks for the recommendations...
3:54 am on Nov 10, 2007 (gmt 0)

Junior Member

5+ Year Member

joined:Oct 2, 2006
posts:187
votes: 0


Habtom,

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

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

Junior Member

5+ Year Member

joined:Oct 2, 2006
posts:187
votes: 0


joelgreen,

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