V
V
vawylon2020-10-20 12:01:11
PHP
vawylon, 2020-10-20 12:01:11

How to change someone else's image from HTTP to HTTPS?

Hello. Straight to the point. I have a website with ssl certificate installed but images without certificate. The problem is that the images are of course blocked because of the mixed connection.
I even experimented. that is, uploaded the image to the server, and then output it as https
Here:

if(isset($_GET['link']))
    {
        $header = get_headers($_GET['link']);
        if(isset($header[2]) && $header[2] == 'Content-Type: image/jpeg')
        {
            header('Content-Type: image');
            

                $lines = @file($_GET['link']);
                $file = fopen($_SERVER['DOCUMENT_ROOT'].'/imgitem/cache/'.md5($_GET['link']), 'w');
                if($lines != NULL)
                {
                    foreach ($lines as $line_num => $line) {
                        echo $line;
                    }
                }
        }
    }

But such a method is resource-intensive!
I have been doing php js html for four months, I don’t even know how to put the question in this matter correctly, tell me in which direction I should go.
I almost forgot!
The image resource is not mine, so the certificate installation will not work.

Right now I'm thinking about downloading all the images using the method above. by adding a list of images and looping through them to load
Links to images there are about 32,000 of them

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nadim Zakirov, 2020-10-20
@zkrvndm

Just proxy pictures through your server and don't worry.

F
FanatPHP, 2020-10-20
@FanatPHP

Alien - no way.
As an option, you can consider the possibility not to parasitize on someone else's content, but to do something of your own

V
Viktor Taran, 2020-10-20
@shambler81

php proxy on the git, lots of examples
and strreplace everything ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question