http://www.vividchanelhandbags.com/images/20000665.jpg这个图片HTTP验证才能打开。写一个函数下载图片。知道验证的账号和密码
test 123789怎么做到呢。怎么通过函数传递账号密码呢?高手帮下

解决方案 »

  1.   

    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;
      

  2.   

    这叫乱码呀?呵呵
    $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;
      

  3.   

    <?php
    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;
    ?>上面的少个头.
      

  4.   

    仔细看我加了这一行
    header("content-type:image/jpg");
    还有注释
    你直接copy代码到你本地运行
      

  5.   

    http://www.php-community.net/html/2011/php_advance_0213/23.html
    PHP HTTP认证的资料