Jump to content

Using PHP To Save An Image on my computer


Exoon

Recommended Posts

Hello,

 

I was wondering if it was possible to get PHP to save a load of images onto my computer.

 

Ive got code to read the website i want the images from and i can get the URL of every image i need but i dont want to manually save them 1by1.

 

Any Help would be great.

 

Thanks!

Yes/No

You can save them to the PHP server.. if thats on your computer then yes..

if its not then you could creates and archive and save that (or have a ton of save prompts for each file)

 

easy option.. install WAMP. create a script to leach the images ie

<?php
$URLs[] = "http://blar.com/images.test1.jpg";
$URLs[] = "http://blar.com/images.test2.jpg";
$URLs[] = "http://blar.com/images.test3.jpg";
$URLs[] = "http://blar.com/images.test4.jpg";
$URLs[] = "http://blar.com/images.test5.jpg";

foreach($URLs as $URL)
{
//save Image to local
$file = file_get_contents($URL);
file_put_contents("SaveImageToPath/".basename($URL),$file);
}
?>

 

EDIT: updated

remember this is a basic example and save all images to the same folder ..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.