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

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

WBOY
Release: 2016-06-13 13:49:33
Original
777 people have browsed it

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( ) )
  {
  $this->m_error .= "打开远程主机出错!";
  return false;
  }

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