How can I display images from my server

  • godlycreations
  • Newbie
  • Newbie
  • godlycreations
  • Posts: 6
  • Loc: Michigan

Post 3+ Months Ago

I have five websites that I am working on, and I need to display the same images on each of them. Each site is different in layout and name, four of the sites are only supposed to read the images, and the fifth site actually uploads the images. I don't have and problems uploading images from the fifth site to a directory within the sites htdocs directory, but I need to upload them and have them stored and viewed from a directory that all five sites can access.

i.e.

the directory structure is as follows:

current image folders
/usr/local/www/vhosts/site1.com/htdocs/images
/usr/local/www/vhosts/site2.com/htdocs/images
/usr/local/www/vhosts/site3.com/htdocs/images
/usr/local/www/vhosts/site4.com/htdocs/images
/usr/local/www/vhosts/site5.com/htdocs/images

This is where I want to store all images so that they can be shared with all five sites.

/usr/local/www/share/images

And then just display the image using the physical location on my server.
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

You could do It via php, but a better solution would be to store them in one of the actual sites, the one you are uploading to. Upload them to a site that can be http'd and then get them using the full url. From any site.
  • godlycreations
  • Newbie
  • Newbie
  • godlycreations
  • Posts: 6
  • Loc: Michigan

Post 3+ Months Ago

All of my sites are built with php and mySQL. So is there some function or class that I have to use in order to do this kind of linking?
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

what sort of linking? If you mean the php method then you will ned the gd extension for graphics. I think that ships with php i think, although I'm not sure. To use it you would have to have a php script that will parse the images. the in the html of the page you would have:

<img src="myscript.php?filename=blah" /> or something.


PHP should be able to directly access the files on your server that are not acessible via http.

An example of this is istockphoto, when you get an image as a preview, it calls a php script, which opens the image, resizes, and adds a copyright notice, then sends the picture. You would not be processing it so it is probably a waste of resources.


If you want to do it the easy way, upload the files to

/usr/local/www/vhosts/site1.com/htdocs/images

and then when you display an image frmo site two you would use:

<img src="http://www.site1domain.com/htdocs/images/filename" />
  • godlycreations
  • Newbie
  • Newbie
  • godlycreations
  • Posts: 6
  • Loc: Michigan

Post 3+ Months Ago

I cannot have any information about the site listed in any of the other sites, because we then run the risk of having viewers finding out that one site is linked to another. Which they are, but users are not supposed to know that. The 4 other sites are all business sites that sell the same things as our main site, but we don't want visitors of the other four sites to know that the stuff they are buying can be bought directly from the main site.

And server space is limited, so I need to find a way share these images from one folder. I am still fairly new to php and mySQL, and this is the biggest project that I have ever been assigned.

My boss is really depending on me to make this happen.
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

It's pretty simple, but I've only skimmed over it and never actually used it - I just know that it can be done.

best bet is to google stuff like
php, images, image-manipulation, gd, tutorial

It is simple so you shouldn't have much problem. All your script will have to do is open the file using the right command and path and then add a header (to indicate the filetype) Thats it.

Good luck to you.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Just put all the images in...

/usr/local/www/share/images

And then turn the others into symbolic links.. From a Bash prompt...

ln -s /usr/local/www/share/images /usr/local/www/vhosts/site1.com/htdocs/images
ln -s /usr/local/www/share/images /usr/local/www/vhosts/site2.com/htdocs/images
ln -s /usr/local/www/share/images /usr/local/www/vhosts/site3.com/htdocs/images
ln -s /usr/local/www/share/images /usr/local/www/vhosts/site4.com/htdocs/images
ln -s /usr/local/www/share/images /usr/local/www/vhosts/site5.com/htdocs/images
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

well there you go then. I think someone was trying to do it the hard way. Nice one axe.
  • godlycreations
  • Newbie
  • Newbie
  • godlycreations
  • Posts: 6
  • Loc: Michigan

Post 3+ Months Ago

Thanks for sticking with me on this, I have been doing searches like that all day long, that is how I found this forum, someone on here had a question about links and images and google found it and sent me here.

I am not going to quit trying though. And yes, I know that the answer is going to be very easy. It is just a matter of finding the right function to use.

If anyone has any ideas, I am really needing more help on this. Well, back to doing some more searching.

Once again, Thank you for sticking with me.
  • godlycreations
  • Newbie
  • Newbie
  • godlycreations
  • Posts: 6
  • Loc: Michigan

Post 3+ Months Ago

Thank you Axe, that looks exactly like the very thing that I have been looking for!

except how do you turn the others into symbolic links?

And what is a Bash prompt?
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Bash is a type of shell that you can access via telnet or SSH (or rlogin, or one of many other ways to connect to a *nix box) - the default shell type on most accounts on a Linux system these days.

So, you need to check with your host that you have access to SSH or telnet. I'm assuming that you have root access to the system? If so, no problem - you are your host, heh :)

You delete the others. Once you've moved all the images from all the directories into /usr/local/www/share/images/

Then just run the ln -s commands (this is what creates the symbolic link) from the shell prompt.

Just make sure that you give /usr/local/www/share/images/ read access to the whole world, so that the other sites can access it.
  • godlycreations
  • Newbie
  • Newbie
  • godlycreations
  • Posts: 6
  • Loc: Michigan

Post 3+ Months Ago

Thank you guys very much for your help! I now have the all the information that I need to share these files between the websites!

Your help is very appreciated!

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 23 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.