1

I'm using header(); to redirect to the file: http://ozonostudio.com/wp-content/uploads/downloads/2012/09/free.psd_.zip

header('Location: ' . $row[3]);

where $row[3] is the value from SQL. This works for all the browsers except for Safari and Opera.

In Opera, it displays the address but doesn't download anything. I'm trying to download files from external URLs. The users add the link to my database with a form.

UPDATE //////////////////

The original URL is: http://ozonostudio.com/wp-content/plugins/download-monitor/download.php?id=3

Safari & Opera show the file address, but that browsers don't start with the download, so what is wrong?

ozonostudio
  • 119
  • 2
  • 6
  • 13
  • 1
    The problem is with the file download itself, most likely. To learn how to force a download, see: http://stackoverflow.com/questions/7470846/send-zip-file-to-browser-force-direct-download – N Rohler Jan 08 '13 at 03:38
  • but i can force the download with external files? and not all the files are zip – ozonostudio Jan 08 '13 at 04:16
  • Make sure nothing is sent to the browser before or after the `header()` call. It's always best to call `exit;` immediately after a `Location` header – Phil Jan 08 '13 at 04:36

1 Answers1

-1

If your database value always return an external download url in that case you should use

header('Content-type: application/pdf'); 
OR header('Content-type: application/zip');

OR desired file format

  • Those headers have nothing to do with a `Location` redirect (302). Any content type headers will be set in the subsequent response – Phil Jan 08 '13 at 04:36
  • i just use this: `$filename = $row[3]; $file_name = basename($filename); header("Content-Type: mime/type"); header("Content-Disposition: attachment; filename=$file_name"); header("Content-Length: " . filesize($filename)); readfile($filename); exit;` and work fine now, i just need create a way to validate the URL – ozonostudio Jan 08 '13 at 05:07