Page 1 of 1

opening uploaded files...

Posted: Wed Apr 20, 2005 2:30 pm
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.

Posted: Wed Apr 20, 2005 4:01 pm
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