vikramy Posted January 22, 2010 Share Posted January 22, 2010 Hi, I am a bit new to php and need some help. This is my situation. I have lots of images on a different sever. And my website is running on a different server. So my code on my website should get the image name from that server and should display it. Can any one help me? Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/ Share on other sites More sharing options...
RichardRotterdam Posted January 22, 2010 Share Posted January 22, 2010 Do you want want to display an image where you know the name of or do need to fetch the image names from a server folder? Or is your situation completely different? And what type of server are you storing the names on? Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-999958 Share on other sites More sharing options...
vikramy Posted January 22, 2010 Author Share Posted January 22, 2010 Thanks for your reply. I need to fetch the image names. Its also a webserver. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-999959 Share on other sites More sharing options...
RichardRotterdam Posted January 22, 2010 Share Posted January 22, 2010 on that webserver where you store the images, can't you use a script that will output the image names? Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-999963 Share on other sites More sharing options...
vikramy Posted January 22, 2010 Author Share Posted January 22, 2010 Thanks again.. I am very poor in explaining though.. I will try again. Users can just see my website. So if they visit say home page of my site, I need to show list of images with their corresponding image name. So those images are in a different web server. So the code needs to be in my website server. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-999969 Share on other sites More sharing options...
simonrs Posted January 22, 2010 Share Posted January 22, 2010 There is no way really that you can read the contents of a directory on another server. That would essentially be hacking. You would need some kind of compliance from the other server, like a script on there that you could remotely call that would output the filenames in a directory. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-999974 Share on other sites More sharing options...
vikramy Posted January 22, 2010 Author Share Posted January 22, 2010 Thanks. Will re think about it.. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-999997 Share on other sites More sharing options...
roopurt18 Posted January 22, 2010 Share Posted January 22, 2010 There is no way really that you can read the contents of a directory on another server. That would essentially be hacking. You would need some kind of compliance from the other server, like a script on there that you could remotely call that would output the filenames in a directory. In this instance that may not be applicable. Let's say the OP's site is: http://www.op.com/page.php Let's say the images reside publicly in: http://www.somedomain.com/images Some of the directory functions make work already with URL locations. Or the OP might be able to say: $page = file_get_contents( 'http://www.somedomain.com/images' ); print_r( $page ); If file_get_contents() works, the OP could parse the page for the image names. The worst case scenario is opening the URL http://www.somedomain.com/images with either HttpRequest or cURL and parsing those results. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-1000099 Share on other sites More sharing options...
vikramy Posted January 22, 2010 Author Share Posted January 22, 2010 [pre]Some of the directory functions make work already with URL locations.[/pre] Can any one tell me more about this. Thanks a ton. file_get_contents() worked!! So I can use , preg_match_all right? Is there a better way? Any one see any downside of this? Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-1000173 Share on other sites More sharing options...
roopurt18 Posted January 22, 2010 Share Posted January 22, 2010 Can any one tell me more about this. There already exist functions to iterate over directories. They might work with URLs the same way that file_get_contents() worked. What was the result from file_get_contents()? Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-1000182 Share on other sites More sharing options...
vikramy Posted January 23, 2010 Author Share Posted January 23, 2010 Everything that http://www.somedomain.com/images has. But after some time I spent with this, I found out that I can get file names from database! Don't say I wasted your time... I learnt a lot... Thank you.. I was believing every image that was other server needs to be displayed.. But it was not the case.. there is some consistent data in our table!! Thanks every one.. Quote Link to comment https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/#findComment-1000252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.