> 写个函数,将 http://www.vividchanelhandbags.com/images/20000665.jpg 这个
> 图片保存到 gbagsell.com 的 images 目录下的 aaa.jpg 这个文件。
<?php
header("Content-Type:image/jpeg");
header("Content-disposition: attachment; filename=\"http://www.vividchanelhandbags.com/images/20000665.jpg\"");
$url = "http://www.vividchanelhandbags.com/images/20000665.jpg";
$ch = curl_init($url);
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
$header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache'); //HEADER信息
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
//USER_AGENT
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt( $ch, CURLOPT_USERPWD , "test:123789");
$response = curl_exec($ch);
echo $response;?>我现在只能实现下载,那两个站都在自己的服务器上,是不是要在服务器上执行脚本命令.exec 这个东西
> 图片保存到 gbagsell.com 的 images 目录下的 aaa.jpg 这个文件。
<?php
header("Content-Type:image/jpeg");
header("Content-disposition: attachment; filename=\"http://www.vividchanelhandbags.com/images/20000665.jpg\"");
$url = "http://www.vividchanelhandbags.com/images/20000665.jpg";
$ch = curl_init($url);
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
$header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache'); //HEADER信息
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
//USER_AGENT
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt( $ch, CURLOPT_USERPWD , "test:123789");
$response = curl_exec($ch);
echo $response;?>我现在只能实现下载,那两个站都在自己的服务器上,是不是要在服务器上执行脚本命令.exec 这个东西
解决方案 »
- QQ 登陆网站后返回数据处理的问题
- 正则匹配问题:匹配ab循环多次的怎么写?即eeeabababeeee中的ab
- 请问哪里有快速安全的MYSQL下载啊
- PHP Notice: Undefined index: submit in D:\PHPWEB\member\user.php on line 4
- 如何通过php调用web service接口
- 怎样将imagejpeg得到的图像作为附件发送邮件?
- 为什么POST过来的sha1加密字符串相等的判断不对呢。
- 获取值问题,请帮帮忙,谢谢
- cookie缓存的问题
- 怎么让这个搞成一个二维数组,js控制,jquery,都可以,提交到后台,后台去解析这个二维数组??急
- 用鼠标指着 一个 词 弹出一个小页面 在线等
- 怎么写动态的变量名?
$url = "http://www.vividchanelhandbags.com/images/20000665.jpg";
$ch = curl_init($url);
$useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
$header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache'); //HEADER信息
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
//USER_AGENT
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt( $ch, CURLOPT_USERPWD , "test:123789");
$response = curl_exec($ch);$filename="images/aaa.jpg";
touch($filename);
$handle = fopen($filename,"rb+");
flock($handle,LOCK_EX);
fwrite($handle,$response);
ftruncate($handle,strlen($response));
fclose($handle);
@chmod($filename,0777);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $url);
$ret = curl_exec($ch);
curl_close($ch);
$magick_wand=NewMagickWand();
MagickReadImageBlob($magick_wand, $ret);
MagickWriteImage($magick_wand, $filename);
$filesize = MagickGetImageSize($magick_wand);
DestroyMagickWand($magick_wand);
return $filesize;
}