Dedecms's Dededown class gets the function of the remote picture as follows, it is valid to pass the past when the call is made, but the following two sentences are found to be null and unable to get the workaround

Source: Internet
Author: User
Dedecms of the Dededown class to get the remote picture of the function as follows, the call passed the past is also valid, but found that the following two calls null cannot be obtained
Dedecms of the Dededown class to get the remote picture of the function as follows, when the call passed the past is also valid, but found the following two sentences for

Empty, unable to get


The function to get the remote picture is used as follows, but it is valid to pass the past when it is called, but the following two sentences are found to be empty, unable to get
$HTD->openurl ($url);

$HTD->gethead ("Content-type")

The above 2-sentence call is empty.


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 "";
}




Downloading files using the HTTP protocol
function Savetobin ($savefilename)
{


if (! $this->isgetok ())
{

return false;
}
if (@feof ($this->m_fp))
{
$this->m_error = "The connection is closed! ";
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;
}



Open the specified URL
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 ();

Initializing the system


$this->privateinit ($url);

$this->privatestartsession ();

}

Start HTTP session
function privatestartsession ($requestType = "GET")
{
if (! $this->privateopenhost ())
{
$this->m_error. = "Error opening remote host!";
return false;
}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.