How to handle media kept on a separate server (PHP)
- by Sandman
So, I have three server, and the idea was to keep all media (images, files, movies) on a media server. I never got around to do it but I think I probably should.
So these are the three servers:
WWW server
DB server
Media server
Visitors obviously connect to the WWW server and currently image resizing and cache:ing is done on the WWW servers as the original files are kept there. So the idea for me is for image functions I have, that does all the image compositioning, resizing and cahceing would just pie the command over to the media server that would return ther path to the finnished file.
What I don't know is how to handle functions such as file_exists() and figuring out image dimensions when needed before even any image management comes into play. Do I pipe all these commands to the other server, via HTTP? I was thinking along the ways of doing it this way:
function image(##ARGS##){
if ($GLOBALS["media_host"] != "localhost"){
list ($src, $width, height) = file('http://$GLOBALS[media_host]/imgfunc.php?args=##ARGS##');
return "<img src='$src' height and width >";
}
.... do other stuff here
}
Am I approaching this the wrong way? Is there a better way to do this?