日期:2014-05-17  浏览次数:20450 次

dedecms的dededown类获取远程图片的函数用如下,调用的时候传递过去的也是有效,但是发现以下两句调用为空 无法获取
dedecms的dededown类获取远程图片的函数用如下,调用的时候传递过去的也是有效,但是发现以下两句为

空,无法获取


获取远程图片的函数用如下,调用的时候传递过去的也是有效,但是发现以下两句为空,无法获取
$htd->openurl( $url );

$htd->gethead( "content-type" )

以上2句调用为空。


function getremoteimage( $url, $rndtrueName )
{
  // echo $url;[img]http://www.golffactorystore.com/images/200910/goods_img/599_P_1255757135855.jpg[/img]
  $revalues = array( );
  $ok = false;
  $htd = new dedehttpdown( );

 
  $htd->openurl( $url );
  //echo $htd->openurl( $url );

  $sparr = array( "image/pjpeg", "image/jpeg", "image/gif", "image/jpg", "image/png", 

"image/xpng", "image/wbmp" );
  
   
  if ( !in_array( $htd->gethead( "content-type" ), $sparr ) )
  {  
  echo "1";
  return "";
   
  }
   

  make_dir( dirname( $rndtrueName ) );
  $itype = $htd->gethead( "content-type" );
   
  $ok = $htd->savetobin( $rndtrueName );
  if ( $ok )
  {
   
  $data = getimagesize( $rndtrueName );
  $revalues[0] = $rndtrueName;
  list( , $revalues[2], $revalues[2] ) = $data;
  }
  $htd->close( );
  if ( $ok )
  {
  return $revalues;
  }
  return "";
}



  
  //用Http协议下载文件
  function savetobin( $savefilename )
  {
   
   
  if ( !$this->isgetok( ) )
  {
   
  return false;
  }
  if ( @feof( $this->m_fp ) )
  {
  $this->m_error = "连接已经关闭!";
  return false;
  }
   
  $fp = fopen( $savefilename, "w" );
  while ( !feof( $this->m_fp ) )
  {
  fwrite( $fp, fread( $this->m_fp, 1024 ) );
  }
  fclose( $this->m_fp );
  fclose( $fp );
  return true;
  }



  //打开指定网址
  function openurl( $url, $requestType = "GET" )
  {
   
  $this->resetany( );
  $this->JumpCount = 0;
  $this->m_httphead = array( );
  //print_r($this->m_httphead);
  /*
  $extend =explode(\".\" , $url);
  $va=count($extend)-1;
  $extend[$va];
   
  $this->m_httphead[""]=
  */
  $this->m_html = "";
  $this->reTry = 0;
  $this->close( );
   
  //初始化系统

   
  $this->privateinit( $url );
   
  $this->privatestartsession();
   
  }

  //开始HTTP会话
  function privatestartsession( $requestType = "GET" )
  {
  if ( !$this->privateopenhost( ) )
  {
&nb