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

php图片保存、上载

WBOY
Release: 2016-06-13 13:03:00
Original
733 people have browsed it

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;
Copy after login
?

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template