get remote images from websites
Posted: Tue Sep 25, 2007 10:50 pm
I'm trying to write a script where basically someone with a picture gallery can enter their url and it will grab all the images off of their gallery...
It uses regex to get the image urls...
The issue is that in order to do a file_get_contents on the image, I need to know the full URL...
Some are relative some are absolute, some use '../' etc... How would you suggest the best way would be to handle this?
I know the original URL... so if for example it is ../, it's easy I can just strip the last dash on the url and concatinate it to the image, if its the full url.. again easy.. but when its relative like /image.jpg, it gets kind of tricky...
Anyone have suggestions for the best way to handle all possible types?
It uses regex to get the image urls...
The issue is that in order to do a file_get_contents on the image, I need to know the full URL...
Some are relative some are absolute, some use '../' etc... How would you suggest the best way would be to handle this?
I know the original URL... so if for example it is ../, it's easy I can just strip the last dash on the url and concatinate it to the image, if its the full url.. again easy.. but when its relative like /image.jpg, it gets kind of tricky...
Anyone have suggestions for the best way to handle all possible types?