Jump to content

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?

 

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()?

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

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.