有个网站A想让我上传一张头像。它使用<input type="file">
的常用形式。
还有B网站,上面有一张我想放在a网站个人资料里的照片。
但是我想把B网站的图片上传到A上,而不需要在我的电脑上下载。相反,我想用Tampermonkey(作为示例)更改网站A上的表单,因此它直接从网站b获取图片。
试试这个代码
$image = imagecreatefromstring(file_get_contents($imageURL));
if (is_resource($image) === true) {
// image is valid, your code
} else {
// not a valid image, show error
}
查看这里的文档:http://php.net/manual/en/function.imagecreatefromstring.php