Home >Backend Development >PHP Tutorial >php图片保存、上载

php图片保存、上载

WBOY
WBOYOriginal
2016-06-13 11:00:57863browse

php图片保存、下载

<?php//获取图片2进制内容 ,可以保存入数据库$imgStr = file_get_contents('http://.../1.jpg');//保存图片$fp = fopen('test.jpg','wb');fwrite($fp, $imgStr);//直接输出图片header("Content-type: image/gif");echo $imgStr;//弹出图片下载框$filename = "1.jpg";//图片地址,可以绝对地址也可以相对地址header("Content-Type: application/force-download");header('Content-Disposition: attachment; filename="'.$filename.'"');$img = file_get_contents($filename);echo $img;
?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn