php 下载图片 打不开,求助各位大神,我的用php写了一个文件下载, 下载后的图片无法打开...

header("Content-Type: text/html; charset=utf-8");

//演示下载文件

$file_name="new.jpg";  //文件名字

//打开文件

if(!file_exists($file_name)){

echo "文件不存在";

return;

}

$file_tp=fopen($file_name,"r");

//获取文件大小

$file_size=filesize($file_tp);

//返回的文件,(包括二进制文件与文本文件)

header("Content-type: application/octet-stream");

//按照字节大小返回

header("Accept-Ranges: bytes");

//返回文件大小

header("Accept-Length: $file_size");

//这里客户端的弹出对话框,对应的文件名

header("Content-Disposition: attachment; filename=".$file_name);

//向浏览器回送数据

$buffe=1024;

//判断文件是否结束

while(!feof($file_tp)){

//读取二进制文件

$file_but=fread($file_tp,$buffe);

//把数据返回给浏览器;

echo $file_but;

}

//关闭文件

fclose($file_tp);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以教你使用 vi 对文本进行段落对齐。请按照以下步骤进行操作: 1. 打开终端并输入 vi 命令以打开 vi 编辑器:`vi filename.txt`(filename.txt 可以替换为你想要的文件名)。 2. 按 `i` 键进入插入模式,输入以下两段文本: ``` Linux is an operating system that was initially created as a hobby by a young student named Linus Torvalds at the University of Helsinki in Finland. He had an interest in Minix, a small UNIX system, and decided to develop a system that exceeded the Minix standards. He began his work in 1991 when he released version 0.02 and worked steadily until 1994 when version 1.0 of the Linux Kernel was released. Linux is widely considered to be the most secure operating system available. It is open-source software, meaning that anyone can access its source code and make changes to it. This has resulted in a large community of developers working to improve the software and fix any bugs or security vulnerabilities that are discovered. ``` 3. 按 `Esc` 键退出插入模式,然后将光标移动到第一行的开头。 4. 按 `Ctrl + V` 键进入可视块模式。 5. 使用方向键将可视块选中,直到选中两段文本的最长行。 6. 按 `Shift + I` 键进入插入模式,输入一个空格,然后按 `Esc` 键退出插入模式。这样,选中的文本就会向右移动一个空格,从而对齐起来了。 7. 按 `Esc` 键退出可视块模式。 8. 输入 `:wq` 命令保存并退出文件。 完成以上步骤后,你的两段文本就会被对齐。希望这对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值