Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 01-26-2004, 04:14 AM   #1 (permalink)
Junkie
 
nukeu666's Avatar
 
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)
nukeu666 is offline  
Old 01-26-2004, 09:01 AM   #2 (permalink)
Banned
 
Location: shittown, CA
sounds like a job for javascript. Not sure if it can but I'd look into tthat....
juanvaldes is offline  
Old 01-26-2004, 09:13 AM   #3 (permalink)
Banned
 
Location: 'bout 2 feet from my iMac
sounds like you need to tweak your apache settings to me... I'm pretty sure you can set it per file-type what the server should allow you to do with it...
cheerios is offline  
Old 01-26-2004, 10:48 AM   #4 (permalink)
Junkie
 
nukeu666's Avatar
 
Location: India
i added this line in apache which didnt work
addtype application/x-blah .mp3
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up?
Because Oct(31) == Dec(25)
nukeu666 is offline  
Old 01-26-2004, 01:44 PM   #5 (permalink)
Darth Papa
 
ratbastid's Avatar
 
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.
ratbastid is offline  
Old 01-26-2004, 11:49 PM   #6 (permalink)
Junkie
 
nukeu666's Avatar
 
Location: India
damn.....IE sux
i hoped there would be a server-side way to do this
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up?
Because Oct(31) == Dec(25)
nukeu666 is offline  
Old 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.
JohnnyRoyale is offline  
Old 01-27-2004, 08:06 AM   #8 (permalink)
Banned
 
Location: 'bout 2 feet from my iMac
except that windows is retarded enough that it won't know what to DO with a ".mpX" once it's on some user's HDD. I'd just put instructions to "right-click save-as" the link, personally.
cheerios is offline  
Old 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.
JohnnyRoyale is offline  
Old 01-27-2004, 10:44 AM   #10 (permalink)
Banned
 
Location: 'bout 2 feet from my iMac
and they'll be intelligent enough to rename a file once it's downloaded?
cheerios is offline  
Old 01-27-2004, 12:28 PM   #11 (permalink)
In Your Dreams
 
Latch's Avatar
 
Location: City of Lights
I'm pretty sure you can give the file a mime type of attachment or something like that, and it sets it to automatically download. I'll do some research and see what I can find. Just wanted to give you a headsup.
Latch is offline  
Old 01-27-2004, 12:35 PM   #12 (permalink)
In Your Dreams
 
Latch's Avatar
 
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
Latch is offline  
Old 01-27-2004, 06:47 PM   #13 (permalink)
Darth Papa
 
ratbastid's Avatar
 
Location: Yonder
Quote:
Originally posted by Latch
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.
Nope. It's Content-Type, for sure. But you can set it to "Content-type: X-Shoveit/Up-Yourass" for all it matters to Internet Explorer. That's the very string that you're changing with by manually setting the MIME type in the server's types file. Changing it with Perl or some other server-side scripting mechanism changes nothing.

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.
ratbastid is offline  
Old 01-27-2004, 08:20 PM   #14 (permalink)
Upright
 
Location: Chico, CA
Probably the easiet method: archive the file (probably zip) and set the link to that file. I realize that this is double-compression, but it is the only way to kick IE into saving the file...

Hope this helps
pythonite is offline  
Old 01-28-2004, 11:36 PM   #15 (permalink)
Junkie
 
nukeu666's Avatar
 
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)
nukeu666 is offline  
Old 01-29-2004, 01:36 AM   #16 (permalink)
Junkie
 
nukeu666's Avatar
 
Location: India
did it atlast

this goes in html file
Quote:

<form action="downloader.php" method="post">
<button type="submit">Righteous Brothers - Unchained Melody</button>
<input type="hidden" name="fol" value="mp3">
<input type="hidden" name="file" value="Righteous Brothers - Unchained Melody.mp3">
</form>
and this is the PHP file
Quote:
<?
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file");
if (!readfile($fol."\\".$file))
?>
not too neat but heck...its my 1st script
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up?
Because Oct(31) == Dec(25)
nukeu666 is offline  
Old 02-11-2004, 11:16 AM   #17 (permalink)
Addict
 
Lord Humungus's Avatar
 
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..
Lord Humungus is offline  
Old 02-11-2004, 01:35 PM   #18 (permalink)
Junkie
 
Location: San Francisco
Quote:
Originally posted by Lord Humungus
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!
It reads the file in the directory $fol with filename $file and writes it to standard output, i.e. the client requesting the page. But it's PHP and I don't know anything about ColdFusion so I can't help you with that part. However if you were using PHP you'd do it exactly the same way with a JPEG, just with a different filename.

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..
n0nsensical is offline  
Old 02-25-2004, 12:02 PM   #19 (permalink)
Addict
 
Lord Humungus's Avatar
 
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!
Lord Humungus is offline  
Old 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.
br00n is offline  
 

Tags
downloads, force


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 04:06 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360