Link to home
Start Free TrialLog in
Avatar of svanlund
svanlund

asked on

Name of downloaded file

Hi!

I have the following script on a site (dl.php):
$size = filesize("/home/b2048/dokument/" . $dok);
header("Content-Type: application/octet-stream");
header("Content-Length: $size");
header("Content-Disposition: inline; filename=$name");
header("Content-Transfer-Encoding: binary");
$fh = fopen("/home/b2048/dokument/" . $dok, "r");
fpassthru($fh);
exit;

It gets the specified file from a folder outside the www-root. When the Save as dialog box pop ups in IE it wants to save the document as dl.php. I want it to save it as the original filename (example: document.doc) without me editing it in the save as dialog. Is it possible to make PHP pass the filename in some way so it doesn't say dl.php?

Thanks!

/David
ASKER CERTIFIED SOLUTION
Avatar of axis_img
axis_img

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of svanlund
svanlund

ASKER

It worked!
I changed the variable to $dok instead of $name.

The points are yours :-)

/david