Help - Search - Members - Calendar
Full Version: MAKING DOWNLOADABLES
HTMLHelp Forums > Web Authoring > General Web Design
Andeeee
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
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
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. smile.gif


QUOTE(Andeeee @ Jun 26 2007, 05:00 AM) *

P.S. you can email me andeeeeeeeeeeeee@hotmail.com (13 eee's)

Why? huh.gif
pandy
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? angry.gif
Johnex
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.
Johnex
basically what i suggested, no?
Darin McGrew
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.