You would need to have a php script to server your images. Something like:
<?php
if(!file_exists('/home/*****/domains/****.com/gallery/' . $_POST['img']))
{
$img = 'NotFound.gif';
}
else
$img = $_POST['img'];
header('Content-Type: image/gif');
echo file_get_contents('/home/*****/domains/****.com/gallery/' . $img);
Now, you'll have to have some error-checking code, and some code to send the correct content-type for the image (i.e. image/gif won't display a jpeg or png image). But this script basically just checks to see if the image file is really there. If the image isn't found, then we use a default "not found" image. Otherwise we use the requested image name. Then we send the header for the image, and then just echo the contents of the image.
Checking for the header to send could be as simple as reading the extension from the image, or use a reversal of the [man]image_type_to_extension/man function to get the image type from the extension, then use [man]image_type_to_mime_type/man to get the correct content-type to send. A simple extension_to_image_type function might look like:
function extension_to_image_type($filename)
{
$extensions = array(
1 => 'gif',
2 => 'jpg',
3 => 'jpeg',
4 => 'png',
5 => 'swf',
6 => 'psd',
7 => 'bmp',
8 => 'tiff',
9 => 'tiff',
10 => 'jpc',
11 => 'jp2',
12 => 'jpf',
13 => 'jb2',
14 => 'swc',
15 => 'aiff',
16 => 'wbmp',
17 => 'xbm',
);
$imageTypes = array(
1 => IMAGETYPE_GIF,
2 => IMAGETYPE_JPG,
3 => IMAGETYPE_JPG,
4 => IMAGETYPE_PNG,
5 => IMAGETYPE_SWF,
6 => IMAGETYPE_PSD,
7 => IMAGETYPE_BMP,
8 => IMAGETYPE_TIFF_II,
9 => IMAGETYPE_TIFF_MM,
10 => IMAGETYPE_JPC,
11 => IMAGETYPE_JP2,
12 => IMAGETYPE_JPX,
13 => IMAGETYPE_JB2,
14 => IMAGETYPE_SWC,
15 => IMAGETYPE_IFF,
16 => IMAGETYPE_WBMP,
17 => IMAGETYPE_XBM,
);
$ext = substr($filename, strrpos('.', $filename)+1);
if($ext === false) return $imageTypes[1];
$type = array_search($ext, $extensions);
if($type === false) return $imageTypes[1];
return $imageTypes[$type];
}
So to get the mime-type you could do:
$mimeType = image_type_to_mime_type(extension_to_image_type($_POST['img']));
Hope that helps.
EDIT: I forgot to mention that storing images outside the document root isn't typically done. Usually things like configuration files which contain passwords and such are kept outside the document root. Images are perfectly fine to be uploaded to a folder inside the document root.