(....用正则提取与拼凑链接的代码...)$urlimg='http://xxx.com';$img_file = file_get_contents($urlimg);file_put_contents('test.jpg', $img_file);
Re-write the question.
I use the above code to download pictures.
But file_get_contents ($URLIMG) wrote this directly and found that the download image failed.
But I use echo $urlimg output address, and then manually write the address file_get_contents (' http://xxx.com '), but normal.
The same is out of the $urlimg, but I wrote it manually, but no problem. is also a variable of plain text.
There is no place to find the problem.
----Update
I have been trying for several days on and off, and when I have just described the problem, I think there will be a coding problem. Various outputs look at what is in the variable. When the content of the $URLIMG variable is saved to the TXT file, it is found that the & symbol in the link is written when it is collected &
, so direct access leads to an error. However, this output does not display a problem on the Web page. Once you have replaced it again, it will be fine.
The problem has been solved how to end the problem?
Reply content:
(....用正则提取与拼凑链接的代码...)$urlimg='http://xxx.com';$img_file = file_get_contents($urlimg);file_put_contents('test.jpg', $img_file);
Re-write the question.
I use the above code to download pictures.
But file_get_contents ($URLIMG) wrote this directly and found that the download image failed.
But I use echo $urlimg output address, and then manually write the address file_get_contents (' http://xxx.com '), but normal.
The same is out of the $urlimg, but I wrote it manually, but no problem. is also a variable of plain text.
There is no place to find the problem.
----Update
I have been trying for several days on and off, and when I have just described the problem, I think there will be a coding problem. Various outputs look at what is in the variable. When the content of the $URLIMG variable is saved to the TXT file, it is found that the & symbol in the link is written when it is collected &
, so direct access leads to an error. However, this output does not display a problem on the Web page. Once you have replaced it again, it will be fine.
The problem has been solved how to end the problem?
Variable assignment in the buffer to see the contents of the PHP related OB
Paste a recently written QR code, please refer to
//开启缓存ob_start();$url = base64_encode($value);$imgPath ="http://pan.baidu.com/share/qrcode?w=280&h=280&url="$url; //png图片$origin = ImageCreateFromPNG($imgPath);//生成图片imagepng($origin);//存入变量$img = ob_get_contents(); $value = iconv("UTF-8", "GBK", $value);//写入文件$handle = fopen($dir_path.'/'.$value.'.png','w'); fwrite($handle, $img);fclose($handle);//关闭缓冲区并不输出,这里看具体需求调整ob_end_clean();
Using Curl