1

my code:

$zip_name="download.zip";
$ctype="application/zip";

// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');

header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");

// change, added quotes to allow spaces in filenames

header("Content-Disposition: attachment; filename=\"".basename($zip_name)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($zip_name));
readfile("$zip_name");

now files download on Downloads folder.

i need download all files in D: drive.

Nasreddine
  • 36,610
  • 17
  • 75
  • 94
arul ananth
  • 11
  • 2
  • 2
  • 3
    I don't think any browsers support this since it would be quite a securtiy threat to allow the website to determine where files should be placed. – Sammaye Aug 11 '12 at 20:42
  • Possible duplicate of http://stackoverflow.com/questions/832486/how-to-set-download-location-for-a-link – FThompson Aug 11 '12 at 20:42

1 Answers1

11

This is not possible. A webserver cannot tell a client where to save a file. Imagine the security implications if a site could specify an exact location for a file save operation.

See RFC 2183, section 2.3:

The receiving MUA SHOULD NOT respect any directory path information
that may seem to be present in the filename parameter
. The filename
should be treated as a terminal component only. Portable
specification of directory paths might possibly be done in the future via a separate Content-Disposition parameter, but no provision is
made for it in this draft.

Community
  • 1
  • 1
Marc B
  • 356,200
  • 43
  • 426
  • 500
  • @Sammaye thanks for your reply.i am working on this script. today is last day.if i found the script.i will post here. – arul ananth Aug 12 '12 at 19:44