用 PHP 进行 HTTP 认证 http://www.vividchanelhandbags.com/images/20000665.jpg这个图片HTTP验证才能打开。写一个函数下载图片。知道验证的账号和密码test 123789怎么做到呢。怎么通过函数传递账号密码呢?高手帮下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ff可以直接以http://test:[email protected]/images/20000665.jpg来访问的.ie7下不识别$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; 这叫乱码呀?呵呵$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);//你获取的是图片二进制内容,要显示图片,就得告诉浏览器,内容格式是什么header("content-type:image/jpg");echo $response; <?phpheader("Content-Type:image/jpeg");$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;?>上面的少个头. 仔细看我加了这一行header("content-type:image/jpg");还有注释你直接copy代码到你本地运行 http://www.php-community.net/html/2011/php_advance_0213/23.htmlPHP HTTP认证的资料 php下载内容为中文的文件时打开为乱码 求救!!php服务器错误!! 祝福兼散分兼问问题 CGI程序的运行权限 数组的问题 转:权限设计 有用质数组成权限集合的,有用2的n次幂组成权限值集合的,我都是用直接将用户和权限代码(自定义格式)存储的,判断时,wh 请高手帮助啊 file输入框的问题。。。! 为什么我使用这个购物车的类的时候第一次总是有错误? php的get方法无法传递中文参数如何解决?100分 如何将文件上传到局域网里的另外一台机器上?--请教宇凡 zend studio8和EclipsePHP Studio3为什么一模一样的? 点击text文本框,内嵌input隐藏的问题
ie7下不识别
$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;
$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);
//你获取的是图片二进制内容,要显示图片,就得告诉浏览器,内容格式是什么
header("content-type:image/jpg");
echo $response;
header("Content-Type:image/jpeg");
$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;
?>上面的少个头.
header("content-type:image/jpg");
还有注释
你直接copy代码到你本地运行
PHP HTTP认证的资料