Answer the question
In order to leave comments, you need to log in
How to get the source code of an image from a link in php?
Hello people.
Such a question:
Here is a captcha link from VK api.vk.com/captcha.php?sid=660914944611
I want to drive it into anti-captcha.com, but I need to drive it there as a source code, a character set in base64 encoded.
I'm trying to get it like this: file_get_contents(' api.vk.com/captcha.php?sid=660914944611 ');
but krakozyabry are returned, as if the encoding is not the same.
In the browser, on the source tab, the code you need is joxi.ru/brRY7jxtvdLMA1
Answer the question
In order to leave comments, you need to log in
function insert_base64_encoded_image_src($img){
$imageSize = getimagesize($img);
$imageData = base64_encode(file_get_contents($img));
$imageSrc = "data:{$imageSize['mime']};base64,{$imageData}";
return $imageSrc;
}
insert_base64_encoded_image('path/to/picture.jpg');
Why so much hassle? Here's the site rucaptcha.com, here they have their own api, and it's easier, you send .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question