01-26-2004, 04:14 AM | #1 (permalink) |
Junkie
Location: India
|
Force Downloads
i've made a page with a link to an mp3 file
now then somebody clicks on that........the mp3 is opened in that page and played.... what i want is when the link is clicked...the (save as...) window should open howcan i do it without using long perl scripts?
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up? Because Oct(31) == Dec(25) |
01-26-2004, 01:44 PM | #5 (permalink) |
Darth Papa
Location: Yonder
|
Here's the deal with this. A browser initiates a request for a file. Could be any old file, a .html, a .gif, an .mp3, whatever. The browser has a MIME type associated with the file extension that it serves to the browser in the header of the file.
If the browser is standards-compliant, it'll have a registered book of helper apps to handle various MIME types, and if it doesn't recognize a particular MIME type, it'll ask what to do--including offering to download the file. If the browser is Internet Explorer, on the other hand, it pays NO attention to the MIME type that the server sends. Instead it looks at the file extension and decides what to do based on that. No amount of MIME type fudging will have any impact on how IE disposes of the file. Try downloading the file in Netscape or Opera and see what happens. I don't have a solution for you except to rename the file to something other than .mp3. Which sucks, I know. |
01-27-2004, 07:06 AM | #7 (permalink) |
Psycho
Location: Boston, MAss., USA
|
Hate to offer a hack, but what the hay...have you tried renaming the extention on the server? IE will see .mp3, check the MIME types, find the extention mapped to the app, and use the app to open the file. If the extention was .mpX, which IE didn't know how to use, it would offer the multiple choice, including save as.
Not a solution, but a workaround.
__________________
I'm gonna be rich and famous, as soon I invent a device that lets you stab people in the face over the internet. |
01-27-2004, 09:17 AM | #9 (permalink) |
Psycho
Location: Boston, MAss., USA
|
true, true, the system won't know what to do with the file once it's downloaded. Of course, you put instructions on the page, some users are too retarded to read them.
__________________
I'm gonna be rich and famous, as soon I invent a device that lets you stab people in the face over the internet. |
01-27-2004, 12:35 PM | #12 (permalink) |
In Your Dreams
Location: City of Lights
|
Nevermind.. you make the Content-Type header a application/attachment or something like that.
Problem is, it requires a bit of Perl or something-else code so when a link is clicked on it generates a "new page" that is the file and sends it to your browser with that Content-Type (it may be Content-Disposition). Your browser prompts you with what you want to do with the file. I think this works regardless of browser. Check out this page for an idea of what I'm talking about.. I realise it's from a mailing list of a guy asking for help, but you can read his code and get the idea. http://lists.w3.org/Archives/Public/...yJun/0000.html |
01-27-2004, 06:47 PM | #13 (permalink) | |
Darth Papa
Location: Yonder
|
Quote:
Every document downloaded has one of those, by the way. The page you're looking at right here had a header sent from tfproject.org to your browser that read "Content-type: text/html\n\n". That "profile" button to the lower left of these words was "Content-type: image/gif\n\n". The server knows what to say by consulting its MIME types file against the extension of the file being sent. |
|
01-28-2004, 11:36 PM | #15 (permalink) |
Junkie
Location: India
|
ppl here not smart enuf to rename the file after i change the extension
i got a little PHP script that sets conteny-tpye to application/octet-stream let see if that works here's the link if ne1 else wants to see 'http://www.faqts.com/knowledge_base/view.phtml/aid/4179/fid/51
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up? Because Oct(31) == Dec(25) |
01-29-2004, 01:36 AM | #16 (permalink) | ||
Junkie
Location: India
|
did it atlast
this goes in html file Quote:
Quote:
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up? Because Oct(31) == Dec(25) |
||
02-11-2004, 11:16 AM | #17 (permalink) |
Addict
Location: The Outer rim of HELL
|
now...how can we do that same thing with a jpeg or gif rather than an mp3 file?
EDIT: can you explain what if (!readfile($fol."\\".$file)) does? Im trying to do the same thin with Cold Fusion and rather than an mp3...do it with a jpg. Thanks!
__________________
I am still searching for the movie this quote was in... "Make you strong, like bull", said in a russian accent Post here if you know anything...PLEASE! Last edited by Lord Humungus; 02-11-2004 at 12:46 PM.. |
02-11-2004, 01:35 PM | #18 (permalink) | |
Junkie
Location: San Francisco
|
Quote:
By the way, that script is a bit of a security risk; all you have to do is change the values of fol and file and you can download any file for which the httpd process has read permission. Also, having register_globals on (where PHP maps the values for fol and file to $fol and $file) is a security risk in general, though probably not with this script, because a user who knows the names of variables in your script can add keys and values to the HTTP request and change the initial values of those variables. Just letting you know. Last edited by n0nsensical; 02-11-2004 at 01:37 PM.. |
|
02-25-2004, 12:02 PM | #19 (permalink) |
Addict
Location: The Outer rim of HELL
|
thats is very valuable information. i didn't even think about that. thanks!
__________________
I am still searching for the movie this quote was in... "Make you strong, like bull", said in a russian accent Post here if you know anything...PLEASE! |
10-15-2004, 12:58 PM | #20 (permalink) |
Upright
|
[CFMX] forcing file download
Hi, Christian Cantrell posted this on this blog. (http://www.markme.com/cantrell/archives/002658.cfm)
Very handy. This could be from a query or pretty much any query type source... <cffile action="readbinary" file="/home/cantrell/Pictures/Corrs2.jpg" variable="pic"/> This 'could' be reduced...why not experiment? <cfscript> context = getPageContext(); context.setFlushOutput(false); response = context.getResponse().getResponse(); out = response.getOutputStream(); response.setContentType("image/jpeg"); response.setContentLength(arrayLen(pic)); out.write(pic); out.flush(); out.close(); </cfscript> It just takes some minor changes to change the content disposition and have the file 'download' to the client. br00n Last edited by br00n; 10-15-2004 at 01:02 PM.. Reason: taggined the thread. |
Tags |
downloads, force |
|
|