Jump to content

File names on a different server


vikramy

Recommended Posts

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.

 

 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

[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?

 

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.