Page 1 of 1

I have a small problem

Posted: Tue Apr 27, 2010 7:56 pm
by halimox
Hello,

I don't know where is the problem in this script :banghead:

1.html :

Code: Select all

<html><body>
<form method="post" action="download.php">
File name: <input type="text" name="FN" size="12"><br>
<input type="submit" value="OK">
</form></body></html>
download.php :

Code: Select all

<?php
$file = $FN;

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>
test.html

Code: Select all

TEST
when I enter 'test.html' in the text field I can't download the file test.html' :(

thank you for your help.

Re: I have a small problem

Posted: Tue Apr 27, 2010 9:38 pm
by yacahuma
I always use the full system path when I download something not just the name.