0

Currently I have a PHP site that will show different links to user to download the files. I am using the following php code for this:

echo "<a href=$link download=\"$id.$fileformat\".>Click Here To Download</a>";
echo '<br>';
echo '<br>';

And when user clicks on the link, it will download the file to the user's machine. But how do I download it to the server itself?

Meaning when clicked, the file will be downloaded to the server and the location of the file in the server will be shown to user.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
aandroidtest
  • 1,493
  • 8
  • 41
  • 68
  • 3
    Download to server...you mean upload? – Dave Chen Jun 05 '13 at 02:25
  • 1
    Ohh I think I get it, you have a remote file that you want to download, but you want to download it first on your machine, and then send it to your client. – Dave Chen Jun 05 '13 at 02:27
  • *sidenote:* download attribute is ONLY supported by Firefox 20+ and Chrome 14+. Missing double quotes in href attribute as well – Raptor Jun 05 '13 at 02:29
  • @DaveChen Yes, correct remote file download to server first. – aandroidtest Jun 05 '13 at 02:32
  • It's really just `file_get_contents($_GET['what_file_to_download'],'dir/to/file')` and then `href='dir/to/file'`, make sure you run `$_GET` through a check (otherwise anyone could download any file from anywhere). – Dave Chen Jun 05 '13 at 02:38

0 Answers0