时间:2021-07-01 10:21:17 帮助过:5人阅读
输出文件内容
<html>
<body>
<form action="download.php" method="GET"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="FileName" id="Fileid" value="<?php echo $_FILES["file"]["name"];?>" />
<h1></h1>
<input type="submit" name="submit" value="download" />
</form>
</body>
</html>
php写的处理文件
<?php
if( empty($_GET['FileName'])){
echo'<script> alert("非法连接 !"); location.replace ("./fileload.html") </script>'; exit();
}
$file_name=$_GET['FileName'];//得到要下载的文件
if (!file_exists($file_name)) { //检查文件是否存在
echo "文件找不到";
exit;
} else {
$file = fopen( $file_name,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/octet-stream");
//Header("Accept-Ranges: bytes");
//Header("Accept-Length: ".filesize( $file_name));
//Header("Content-Disposition: attachment; filename=" . $file_name);
//