Hide download URL

Hi.
I need to have a script that gives people download of a file but doesn’t let them have the URL of that file. I’ve looked it up in this forum and others and there are many posts on this, most of them present the same solution but it doesn’t seem to be working with me. What can be wrong?

I get errors and pages full of weird characters and question marks as if the browser is trying to read the zip file… Tried it with Safari and Firefox and it’s the same problem.
:frowning:

Thanks

[php]<?php

$dir=“file/directory”;
if (isset($_REQUEST[“file”])) {
$file=$dir.$_REQUEST[“file”];
header(“Content-type: application/octet-stream”);
header(“Content-Transfer-Encoding: Binary”);
header(“Content-length: “.filesize($file));
header(“Content-disposition: attachment; filename=””.basename($file).”"");
readfile("$file");
} else {
echo “No file selected”;
}

?>[/php]

If it’s a zip file wouldn’t you want to use application/zip ?

Thanks!
I figured it out. I had [php][/php] before the php code.

Sponsor our Newsletter | Privacy Policy | Terms of Service