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
https://forums.phpfreaks.com/topic/189437-file-names-on-a-different-server/
Share on other sites

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?

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.

 

 

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.

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.

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

 

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

Archived

This topic is now archived and is closed to further replies.

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