A
A
Anton Shelestov2015-08-27 23:51:52
PHP
Anton Shelestov, 2015-08-27 23:51:52

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

3 answer(s)
S
Stalker_RED, 2015-08-28
@Stalker_RED

php.net/manual/en/book.curl.php

V
Vlad Pasechnik, 2015-08-28
@jumper423

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');

B
Baha Rustamov, 2015-08-28
@by133312

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 question

Ask a Question

731 491 924 answers to any question