PHP从PHP脚本生成的URL下载图像

时间:2018-10-29 19:58:35

标签: php

我有问题。我需要从URL下载图像,但图像URL不能以JPG,PNG或其他一些img文件类型结尾。该图像由PHP脚本生成。

这是一张图片: https://www.baza-firm.com.pl/includes/adem.php?usr=Yml1cm8=&dmn=dG9wYXotbWV0YWxlLmNvbS5wbA==&mobEml=0

我如何使用PHP脚本下载此图像?

1 个答案:

答案 0 :(得分:0)

如果您在php.ini中拥有void Int_To_Text(int num) { int first = num/10; int second = num % 10; if (num >= 11 && num <=20) { switch (num) { case 11: cout << "Eleven"; break; case 12: cout << "Twelve"; break; case 13: cout << "Thirteen"; break; case 14: cout << "Fourteen"; break; case 15: cout << "Fifteen"; break; case 16: cout << "Sixteen"; break; case 17: cout << "Seventeen"; break; case 18: cout << "Eighteen"; break; case 19: cout << "Nineteen"; break; case 20: cout << "Twenty"; break; } } else { switch (first) { case 1: if (second == 0) cout << "Ten"; case 2: cout << "Twenty"; break; case 3: cout << "Thirty"; break; case 4: cout << "Fourty"; break; case 5: cout << "Fifty"; break; case 6: cout << "Sixty"; break; case 7: cout << "Seventy"; break; case 8: cout << "Eighty"; break; case 9: cout << "Ninety"; break; case 10: cout << "One Hundred"; break; } if(first > 1 && num != 100) cout << " "; switch (second) { case 1: cout << "One"; break; case 2: cout << "Two"; break; case 3: cout << "Three"; break; case 4: cout << "Four"; break; case 5: cout << "Five"; break; case 6: cout << "Six"; break; case 7: cout << "Seven"; break; case 8: cout << "Eight"; break; case 9: cout << "Nine"; break; default: break; } } return; } int main() { int num; int c = 1; cout << "Please enter a number you would like to convert" << endl; cin >> num; if(num > 100) cout << "Please enter a number between 1 and 99"; else { for(int i = 1; i <=num; i++) { Int_To_Text(c); c++; cout << endl; } } return 0; } ,则可以使用file_get_contents

allow_url_fopen=1

,否则,如果您安装了php-curl,则可以使用curl

$image_binary=file_get_contents($url);

。如果您既没有allow_url_fopen也没有curl,则可以使用socket api

$ch=curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$image_binary=curl_exec($ch);