How to Download Images with PHP

Asked

Viewed 535 times

1

Guys I have an urgent question.

I want to be able to download images using php, these image URL are in a spreadsheet of google Docs, I was able to make the connection, and I was able to make a code to download, but the file you see me and different from what I expected:

Image url: inserir a descrição da imagem aqui

Code I am using:

<?php
$url_do_arquivo = "https://docs.google.com/spreadsheets/d/e/2PACX-1vQ-J4JhsR1TFU9iKPJFPOE77U2VqYECdGp9eiP1_XRbUaLEoZu8PjrdODrxxSSsl7mBQRks3T_Y9WTy/pub?output=csv";
if (($identificador = fopen($url_do_arquivo, 'r')) !== FALSE) {
echo '<pre>';

while (($linha_do_arquivo = fgetcsv($identificador, 0, ",")) !== FALSE) {


    printf("%-10s %-19s  <br />",  $linha_do_arquivo[1], $linha_do_arquivo[3]);

    file_put_contents($linha_do_arquivo[1],file_get_contents($linha_do_arquivo[3]));
}
echo '</pre>';

fclose($identificador);
} else {


echo 'Não foi possível abrir o arquivo';
}

You are really downloading, but what is a text file of the url with what if I’m not mistaken and a kind of CSS of the image, but I need the image itself.

How to solve this ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.