Hello everyone,
I have just written a PHP script to wget any image.
All you need to do is get the full path of your image e.g.
http://www.google.co.in/images/srpr/logo3w.png is path to google logo.
So now lets wget google's logo.
<?php
$mainimage = "http://www.google.co.in/images/srpr/logo3w.png"; //this would be the path of your live image which you want to download
$thebasename = basename($mainimage); //here we will get logo3w.png i.e. name of file
$filename = explode(".", $thebasename); //explode it with extention
$i=0;
do {
if($i > 0) $filename[0]++;
else $filename[0] = $filename[0].$i;
$i++;
}while(file_exists("tmp_cover/".$filename[0].".".$filename[1])); //typical do while to check for unique file name
$image_dir = "tmp_cover/"; //this will be your directory where you want to save your image
$fresh_file = $filename[0].".".$filename[1]; //this is our renamed file if file already exists
$image_drs = $image_dir.$fresh_file; //i have concatinated the path so it becomes easier to use in wget function
system("wget -q \"$mainimage\" -O $image_drs"); //image uploaded with wget -q
/*
Notes:
1)Please check if your wget version is wget v1.12 and php is php v5.3.1 or greater.
2)Give full permissions to your files (chmod 777 your_dir) or use filezilla client to give full permission to your folder.
3)I have created tmp_cover folder at /opt/lampp/htdocs with 777 permissions.
/*
?>
I have just written a PHP script to wget any image.
All you need to do is get the full path of your image e.g.
http://www.google.co.in/images/srpr/logo3w.png is path to google logo.
So now lets wget google's logo.
<?php
$mainimage = "http://www.google.co.in/images/srpr/logo3w.png"; //this would be the path of your live image which you want to download
$thebasename = basename($mainimage); //here we will get logo3w.png i.e. name of file
$filename = explode(".", $thebasename); //explode it with extention
$i=0;
do {
if($i > 0) $filename[0]++;
else $filename[0] = $filename[0].$i;
$i++;
}while(file_exists("tmp_cover/".$filename[0].".".$filename[1])); //typical do while to check for unique file name
$image_dir = "tmp_cover/"; //this will be your directory where you want to save your image
$fresh_file = $filename[0].".".$filename[1]; //this is our renamed file if file already exists
$image_drs = $image_dir.$fresh_file; //i have concatinated the path so it becomes easier to use in wget function
system("wget -q \"$mainimage\" -O $image_drs"); //image uploaded with wget -q
/*
Notes:
1)Please check if your wget version is wget v1.12 and php is php v5.3.1 or greater.
2)Give full permissions to your files (chmod 777 your_dir) or use filezilla client to give full permission to your folder.
3)I have created tmp_cover folder at /opt/lampp/htdocs with 777 permissions.
/*
?>
ReplyDeleteIn recent days Angular plays vital role to loading your site content in a fastest way, so it’s a required skill for everyone, thanks for sharing this useful information to our vision keep blogging.
Regards,
Angularjs training in chennai
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteangularjs Training in marathahalli
angularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in chennai
automation anywhere online Training
I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog.
ReplyDeleteJava training in USA
Java training in Bangalore | Java training in Indira nagar
Java training in Bangalore | Java training in Rajaji nagar
Java training in Bangalore | Java training in Marathahalli
This is ansuperior writing service point that doesn't always sink in within the context of the classroom. In the first superior writing service paragraph you either hook the reader's interest or lose it. Of course your teacher, who's getting paid to teach you how to write an good essay,
ReplyDeletepython training Course in chennai
python training in Bangalore
Python training institute in bangalore
This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.
ReplyDeleterpa training in chennai
rpa training in bangalore
rpa course in bangalore
best rpa training in bangalore
rpa online training
I was in search of this blog for a while and just now got this into my vision Thanks for sharing.
ReplyDeleteSpoken English Class in Chennai
Spoken English Institute in Chennai
English Coaching Classes in Chennai
English Coaching in Chennai
English Learning Institute near me
English Coaching Centre in Chennai
English Classes in Chennai
Interesting blog, it gives lots of information to me. Thanks for sharing such a nice blog.
ReplyDeleteData Science Training in Chennai
Big Data Analytics Courses in Chennai
Machine Learning Training in Chennai
Microsoft Azure Training in Chennai
DevOps Training in Chennai
AWS Training in Chennai
Data Science Training in OMR
Data Science Training in Porur
It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
ReplyDeleteData science Course Training in Chennai | No.1 Data Science Training in Chennai
RPA Course Training in Chennai | No.1 RPA Training in Chennai
AWS Course Training in Chennai | No.1 AWS Training in Chennai
Devops Course Training in Chennai | Best Devops Training in Chennai
Selenium Course Training in Chennai | Best Selenium Training in Chennai
english to kannada typing
ReplyDeleteimo for pc
ReplyDeleteNice content very helpful, It has a very important point which should be noted down. All points mentioned and very well written.Keep Posting & writing such content
ReplyDeleteAWS Online Training
Online AWS Certification Training
I genuinely appreciated understanding it. Sitting tight for some more incredible articles like this from you in the nearing days.
ReplyDeleteData Science Training In Bangalore
Data Science Training Institute in Bangalore