欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP實(shí)現(xiàn)微信圖片上傳到服務(wù)器的方法示例

 更新時(shí)間:2017年06月29日 10:33:12   作者:a771948524  
這篇文章主要介紹了PHP實(shí)現(xiàn)微信圖片上傳到服務(wù)器的方法,涉及php基于curl操作圖片文件的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP實(shí)現(xiàn)微信圖片上傳到服務(wù)器的方法。分享給大家供大家參考,具體如下:

$pic_img=trim( $postObj->PicUrl);
if($type=="image"){
  $pic_url=save_file_to_sever($pic_img,$fromUsername);
}
   GetRootPath(){
  $sRealPath = realpath('./');
  $sSelfPath = $_SERVER['PHP_SELF'];
  $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
  return substr($sRealPath, 0, strlen($sRealPath) - strlen($sSelfPath));
}
function save_file_to_sever($url,$fromid){
  $gen=GetRootPath();
  $time=time();
  $newfname =$gen."/weixin/wx_huodong/xiawucha/".$fromid.$time.'.jpg';
  $ch=curl_init();
  $timeout=5;
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  $img=curl_exec($ch);
  curl_close($ch);
  $size=strlen($img);
  //文件大小
  $fp2=@fopen($newfname,'a');
  fwrite($fp2,$img);
  fclose($fp2);
  return "http://www.xxx.com/weixin/wx_huodong/xiawucha/".$fromid.$time.'.jpg';
}

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP微信開發(fā)技巧匯總》、《PHP編碼與轉(zhuǎn)碼操作技巧匯總》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語(yǔ)法入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門教程》及《php常見數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論