Jump to content

I have a small problem


halimox

Recommended Posts

Hello,

 

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

 

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'    :facewall:

 

thank you for your help.

Link to comment
https://forums.phpfreaks.com/topic/199992-i-have-a-small-problem/
Share on other sites

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'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.