dedecms的dededown类获取远程图片的函数用如下,调用的时候传递过去的也是有效,但是发现以下两句调用为空 无法获取解决方法
程序员文章站
2022-06-13 10:03:56
...
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;
}
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;
}
相关文章
相关视频
上一篇: PHP基础之POST与GET,phppostget
下一篇: PHP过滤★等特殊符号的正则