MAKING DOWNLOADABLES, Example: Click on the link or picture, and it asks you to open, save, |
MAKING DOWNLOADABLES, Example: Click on the link or picture, and it asks you to open, save, |
Andeeee |
Jun 25 2007, 09:58 PM
Post
#1
|
Group: Members Posts: 3 Joined: 25-June 07 Member No.: 3,192 |
Hey, can u guys tell me how to do this:
I have a downloads page on my website. How do i make donwloads? Example: Click on the link or picture, and it asks you to open, save, and that sort of thing.... HOW DO I DO IT? Thankyou P.S. you can email me andeeeeeeeeeeeee@hotmail.com (13 eee's) |
lavazza |
Jun 25 2007, 10:37 PM
Post
#2
|
Member Group: Members Posts: 60 Joined: 25-June 07 Member No.: 3,191 |
Prompting to open/save is what a browser will do if it does NOT know how to open the file you have linked to
E.g all (decent) browsers by default will have no problems opening files with extensions like .html, .pdf, .css, .jpeg, .txt etc But they don't (by default) know what to do with a .doc or .xls file So... clicking on <a title="907kB MS Word document" href="folderName/myWordDocument.doc">My Word Document</a> WILL prompt the user to open/save <a title="link to: myPdfFile.pdf : 42kB pdf file" href="folderName/myPdfFile.pdf">My PDF File</a> WON'T prompt the user to open/save |
pandy |
Jun 26 2007, 08:04 AM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
I don't think you can. That's the browser's default dialog for files it can't display. It can display images (in certain formats anyway). You could zip the image, but I don't see the point. I think everyone knows how to save an image to their computer.
P.S. you can email me andeeeeeeeeeeeee@hotmail.com (13 eee's) Why? |
pandy |
Jun 26 2007, 08:10 AM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
Please don't post the same question all over the place. I've merged the threads now. When I wrote the above I hadn't seen lavazza's answer in another of your threads. Double posting makes the forum messy and wastes people's time. OK?
|
Johnex |
Jun 26 2007, 08:40 AM
Post
#5
|
Newbie Group: Members Posts: 10 Joined: 18-June 07 Member No.: 3,109 |
You can make a php server side script to do that.
You just send a special oclet stream header before the file like so: CODE <?php $speed_limit_on = '1'; // Set this to 1 or 0 $speed = 25; // 25KB/s $file = $_SERVER['DOCUMENT_ROOT'].$_GET['f']; if(file_exists($file) && is_file($file)) { $file_name = explode($slash,$file); $file_name = $file_name[(count($file_name) - 1)]; header('Content-Type: application/octet-stream'); header('Content-Length: '.filesize($file)); header('Content-Disposition: filename="'.$file_name.'"'); flush(); // Download File With Limits $fd = fopen($file,'r'); while(!feof($fd)) { print fread($fd, round($speed * 1024)); flush(); if($speed_limit_on) sleep(1); } fclose($fd); } ?> Edit the speed limit and speed in kB/s you want, and save this in a file called download.php on the root of your server, and link the files like so: <a href="www.YOURSITE.com/download.php?f=/FILENAME">FILENAME</a> It may also contain dirs: www.YOURSITE.com/download.php?f=/DIR1/SUBDIR1/../FILE Hope this helps. This post has been edited by Johnex: Jun 26 2007, 08:46 AM |
Darin McGrew |
Jun 26 2007, 10:47 AM
Post
#6
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
|
Johnex |
Jun 26 2007, 12:31 PM
Post
#7
|
Newbie Group: Members Posts: 10 Joined: 18-June 07 Member No.: 3,109 |
basically what i suggested, no?
|
Darin McGrew |
Jun 26 2007, 09:19 PM
Post
#8
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
The FAQ entry explains the Content-disposition header specifically, and provides links to additional information. Also, it isn't tied to a particular PHP implementation.
|
Lo-Fi Version | Time is now: 19th April 2024 - 10:01 PM |