MasterK Posted October 27, 2009 Share Posted October 27, 2009 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 https://forums.phpfreaks.com/topic/179141-download-image-from-url-and-upload-it/ Share on other sites More sharing options...
Garethp Posted October 27, 2009 Share Posted October 27, 2009 I believe GD2 can download and save the images http://www.google.com/search?hl=en&q=gd2+tutorial&aq=f&oq=&aqi=g1g-m1 For the first 6 letters, use http://php.net/manual/en/function.substr.php Remaing http://php.net/manual/en/function.rename.php The every 20 minutes part is called a Cron job http://www.google.com/search?hl=en&ei=93zmSprxNIWCkAWy8IjKBg&sa=X&oi=spell&resnum=0&ct=result&cd=1&ved=0CAYQBSgA&q=cron+job&spell=1 Link to comment https://forums.phpfreaks.com/topic/179141-download-image-from-url-and-upload-it/#findComment-945140 Share on other sites More sharing options...
MasterK Posted October 27, 2009 Author Share Posted October 27, 2009 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.. Link to comment https://forums.phpfreaks.com/topic/179141-download-image-from-url-and-upload-it/#findComment-945167 Share on other sites More sharing options...
dreamwest Posted October 27, 2009 Share Posted October 27, 2009 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 :-\ Link to comment https://forums.phpfreaks.com/topic/179141-download-image-from-url-and-upload-it/#findComment-945169 Share on other sites More sharing options...
MasterK Posted October 27, 2009 Author Share Posted October 27, 2009 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 Link to comment https://forums.phpfreaks.com/topic/179141-download-image-from-url-and-upload-it/#findComment-945171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.