在HP-UX上使用PHP下载文件程序 [英] Download file program using PHP on HP-UX box
问题描述
我无法修改我的PHP程序。最初,该程序会从Unix框下载一个特定的文件,它运行良好。现在我已经对它进行了一些修改,以便用户可以输入文件名进行下载。
现在不工作了,我不知道为什么。它不会抛出任何我能看到的错误;
PHP版本 - 5.2.13
Apache - 2.0
Unix Box - HP-UX 11.11(旧版本;最新版本为11.31)
本地PC - Windows XP Pro
浏览器 - IE 7,Mozilla
代码:
< html>
< body>
<?php
ob_start();
if(isset($ _ POST ['name']))
{
$ file = $ _POST ['name'];
echofile is $ file;
if(!file_exists($ file))
{
die(file not found:);
}
$ name = basename($ file);
header('Content-Description:File Transfer');
header('Content-Type:application / octet-stream');
header('Content-Disposition:attachment; filename =''。$ name。''');
header('Content-Transfer-Encoding:binary');
header('Expires:0');
header('Cache-Control:must-revalidate');
header('Pragma:public');
header('Content-Length:'。filesize($ file));
ob_clean();
readfile($ file);
出口;
}
else
{
echo< form action ='download1.php'method ='post'enctype = 'multipart / form-data'>
< b>输入文件名称:< / b>< input type ='text'name ='name'>
< br>< br>
< button type ='submit'>上传< / button>
< / form>;
}
?>
< / body>
< / html>
我做错了什么?
我解决了问题,我只是从我的代码中删除了标签,并且它工作正常。它似乎输出缓冲,并且它没有发送到浏览器或它不能从缓冲区根据我的理解显示或运作...感谢您的时间家伙...
I'm having trouble modifying my PHP program. Originally, the program would download a particular file from a Unix box, which worked fine. Now I've modified it a little so the user can enter a file name to download.
Now it's not working, and I'm not sure why. It doesn't throw any errors that I can see; the page simply returns blank.
PHP version - 5.2.13
Apache - 2.0
Unix Box - HP-UX 11.11 (old version; latest is 11.31)
local PC - Windows XP Pro
Browser - IE 7, Mozilla
Code:
<html>
<body>
<?php
ob_start();
if(isset($_POST['name']))
{
$file = $_POST['name'];
echo "file is $file" ;
if(!file_exists($file))
{
die("file not found: " );
}
$name = basename($file);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$name.'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
readfile($file);
exit;
}
else
{
echo " <form action='download1.php' method='post' enctype='multipart/form-data'>
<b> Enter the file name: </b><input type='text' name='name'>
<br> <br>
<button type='submit'> Upload </button>
</form>";
}
?>
</body>
</html>
What am I doing wrong?
I got it solved, I just removed tags from my code and it worked fine..It seems that output was buffering and either it was not sent to browser or it could not come out of buffer to display or to function as per my understanding..thanks for your time guys...
这篇关于在HP-UX上使用PHP下载文件程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!