Closed Thread Icon

Topic awaiting preservation: File download Pages that link to <a href="https://ozoneasylum.com/backlink?for=12299" title="Pages that link to Topic awaiting preservation: File download" rel="nofollow" >Topic awaiting preservation: File download\

 
Author Thread
DreamiX
Nervous Wreck (II) Inmate

From: Berlin, Germany
Insane since: Jun 2002

posted posted 07-05-2002 14:40

Hello together!
I have a special question on downloads:
I developed an intranet-application with JSP, which stores documents on the server and allows the user to search for them and download the documents he wants. My problem is: I offer the documents as an HTML-link in the <a href=""...>-fashion. Unfortunately with most document-types the browser immediately opens a new window showing the content as ascii, which is not nice with pictures for example. Instead I would like either opening the download&save-dialog like choosing "save target as" in the browser, or, even better, opening the document over the intranet but with the correct application (in this case, the registered graphics-program). Can you help me with this? I would be very pleased. Greetings, DreamiX.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 07-05-2002 14:51

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-06-2002 11:41

DreamiX, i have used this nice PHP code:

code:
<?php
//Put this script in the header of a file
//You can submit $Dir, $File_Name, $File_Extension by another script

$filename="filename";
$fileextension="zip";
$filedir = "c:/elias/zips/";

$fnsave = "$filename.$fileextension";
$fnread = "$filedir$filename.$fileextension";

header("Content-disposition: filename=$fnsave");
header("Content-type: application/force-download");
readfile("$fnread");
?>



hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 07-08-2002 14:58

i'm betting the "force-download" mime-type is forcing the browser to treat every file as plain/text.

DreamiX
Nervous Wreck (II) Inmate

From: Berlin, Germany
Insane since: Jun 2002

posted posted 07-08-2002 15:58

A little jsp-code would be nice, since my own didn't work.
That's the download.jsp:

<%
String strFile = request.getParameter("file");
response.setContentType("application/msword");
%>
<jsp:include page='<%=strFile%>' flush="true" />

But instead of downloading the file, I just get a 2-bytes-download.jsp?!

DreamiX
Nervous Wreck (II) Inmate

From: Berlin, Germany
Insane since: Jun 2002

posted posted 07-11-2002 11:07

No example code necessary any more, I wrote a servlet that works.

The MIME-Type "application/force-download" is fine, but there is one further problem: if i download the files, they are mostly correct, but in some cases the filename is replaced. The file-extension remains the original one, but the file name is replaced by "download", which is the name of my servlet. E.g. if I have a file "picture.pcx" and try to download it with my servlet the download-dialog asks for downloading "download.pcx". The file itself is the same as the original, but the name changed. How can I prevent this?

« BackwardsOnwards »

Show Forum Drop Down Menu