drakeshe
asked on
Save image & keep structure in PHP
Im currently working on a way to archive webpages using PHP. What I am currently stumped with is the a way on how I can save images from the page and keep the same folder structure.
So far I have extracted the URL to the image. What im left with is:
www.testsite.com/img/main/layout/head_image_cc_09.jpg
what I need to do now is copy that image to my server and still have the correct file structure.
for example I want it to be like this:
copy testsite.com/img/main/layo ut/head_im age_cc_09. jpg
to www.mysite.com/archive/testsite.com/img/main/layout/head_image_cc_09.jpg
Any ideas?
EDIT: Maybe to make it a bit easier, maybe even a way to remove everything before the filename and the file extension. So like change 'testsite.com/img/main/lay out/head_i mage_cc_09 .jpg' to just head_image_cc_09.jpg. I would actually though have to be able to remove the filename and not just get image properties. Like remove all characters before and including the / symbol.
I would really really much prefer the first idea, but if thats not plausible then I guess the second way should be alright, but would require much more work.
So far I have extracted the URL to the image. What im left with is:
www.testsite.com/img/main/layout/head_image_cc_09.jpg
what I need to do now is copy that image to my server and still have the correct file structure.
for example I want it to be like this:
copy testsite.com/img/main/layo
to www.mysite.com/archive/testsite.com/img/main/layout/head_image_cc_09.jpg
Any ideas?
EDIT: Maybe to make it a bit easier, maybe even a way to remove everything before the filename and the file extension. So like change 'testsite.com/img/main/lay
I would really really much prefer the first idea, but if thats not plausible then I guess the second way should be alright, but would require much more work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.