halimox Posted April 28, 2010 Share Posted April 28, 2010 Hello, I don't know where is the problem in this script 1.html : <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 : <?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 TEST when I enter 'test.html' in the text field I can't download the file test.html' thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/199992-i-have-a-small-problem/ Share on other sites More sharing options...
Alex Posted April 28, 2010 Share Posted April 28, 2010 You need to be more specific. Have you done any debugging that tells you where it's going wrong? The first thing that jumps out at me is that you're relying on register_globals which is depreciated and not suggested. $file = $_POST['FN']; Quote Link to comment https://forums.phpfreaks.com/topic/199992-i-have-a-small-problem/#findComment-1049688 Share on other sites More sharing options...
halimox Posted April 28, 2010 Author Share Posted April 28, 2010 Great ! Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/199992-i-have-a-small-problem/#findComment-1049692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.