是否可以不必在类型文件的输入字段中浏览计算机中的文件,而是从另一个网站获取它?
问题描述:
There is website A that wants me to upload a profile picture. It uses a usual form with <input type="file">
.
Then there is website B, that has a picture I would like to have in my profile on website A.
But I would like to upload the picture from website B on A, without having to download it on my PC. Instead I would like to change the form on website A with Tampermonkey (as example) so it takes the picture directly from website B.
答
Try this code
$image = imagecreatefromstring(file_get_contents($imageURL));
if (is_resource($image) === true) {
// image is valid, your code
} else {
// not a valid image, show error
}
See documentation here: http://php.net/manual/en/function.imagecreatefromstring.php