opening uploaded files...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dannymc1983
Forum Commoner
Posts: 80
Joined: Wed Feb 16, 2005 7:24 am

opening uploaded files...

Post by dannymc1983 »

I have created some scripts which upload files to a server. The name and location of the files is stored in a database but the acutal files are stored on the server. Now, to download the files i simply have created a hyperlink to the files using the location stored in the database. like this:

Code: Select all

//$file_name = some function to get name of the file from the database
//$file_location = some function to get location of the file from the database

echo "<a href = '$file_location'>$file_name</a>";
i assume this is the right way of doing it????
anyway it works but the problem is that it opens the file in the browser window. like if it is a word file or a jpg, it is embedded within the browser. i find this extremely annoying. I would just like a way for the file to be opened using its default application, like for a word file to open in word and not a browser!
or even better, if the download dialog were to appear and ask you if you would like to open the file or save it! can anyone help thanks.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

create a new page you should. A page that uses header() this should be.

then select the file from the database you could and use the appropriate header type you should.

a lot of different options you will have for d/ling, displaying etc.

Jcart | fixed link for ya
Post Reply