Jump to content

Download Image from URL and Upload it


MasterK

Recommended Posts

Ok, I have been googling for the last 1/2 hour trying to figure this out, Most likely I'm just not searching for the right thing.

 

Here is what I want to do.

 

I want to have a Text box which somebody will paste a URL into. The URL will be a PHP Image (Example)

 

Now I want it to download that image as a JPEG to my Website, and name it that last 6 numbers of the URL (for the Example about it would be 185950.jpeg)

 

Then I want it to redownload, and name it every 20minutes

 

I just need pointed in the right direction here, because my Google searches are turning up nothing at all  :-[

 

Thanks

Link to comment
Share on other sites

Ok, So I was frustrated and before anybody had replied, I figured eh, What the heck, Imma try something crazy! and it WORKED!

 

Here is what I am talking about.

 

$url = "http://photo.playerdex.com/trainercard.php?ID=";

$ourFileName = "$str.jpeg";
$ourFileHandle = fopen($ourFileName, 'w')
fclose($ourFileHandle);


$link = $url.$str;
$source = file_get_contents($link);
$myFile = "images/tc/$ourFileName";
$fh = fopen($myFile, 'w')
fwrite($fh, $source);
fclose($fh);

 

I did not think this would work, But I thought I would try it anyways, and it works! This might not be surprising to many people, but I was surprised.

 

Now I just need to get the Cronjob setup, I need to figure out how to make it update all the images that have been created..  :P::)

Link to comment
Share on other sites

Now I just need to get the Cronjob setup, I need to figure out how to make it update all the images that have been created..  

 

Continually update an image that hasnt changed?? I thought i was bored :-\

 

lol?

 

Who said it didn't change? Not I...

 

The image is generated from a Database based on your current team in the game, It updates quite often  :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.