Jump to content

[SOLVED] server centralized images for multiple domains


webent

Recommended Posts

Hi, I was wondering if it is possible to have images located in a place on a server where any domain can call them up via secure site?

 

For example, say you have 125,000 images, you have 200 plus domains, instead of copying all those images to each and every domain... Lots of disk space... have them in like /home/images/ and perhaps like a function that does some type of grabbing the image and creating a virtual secure link of it... ?

 

A function that somehow transforms "/home/images/image.jpg" into "https://www.theirdomain.com/images/image.jpg"

Why just assign /home/images/ it's own domain or subdomain?

 

So https://www.theirdomain.com will go to /home/html

and https://images.theirdomain.com will point to /home/images

 

I could be completely wrong as I don't know much about https, but based on my knowledge that would be my first try.

I found a very comprehensible tutorial on correctly storing large amounts of binary data in blobs, utilizing two tables and splitting the binary data... Here's where I found it, http://www.dreamwerx.net/phpforum/?id=1 ... I just need help with one part of it... I can't figure out why on the calling page, the code wants to download the picture instead of showing it... Please help... Here's the calling page code...

 

<?
// Download script.. streams data from a mysql database, thru the webserver to a client browser

if (isset($_GET["id"])) {

$Storage_IP = "localhost";
$Storage_Port = 3306;
$Storage_User = "";
$Storage_Passwd = "";
$Storage_DB = "";

  $connectto = $Storage_IP . ":" . $Storage_Port;

  if (!$linkid = @mysql_connect($connectto, $Storage_User, $Storage_Passwd)) {
    die("Unable to connect to storage server!");
  }

  if (!mysql_select_db($Storage_DB, $linkid)) {
    die("Unable to connect to storage database!");
  }

  $nodelist = array();

  // Pull file meta-data
  $SQL = "select * from file where id = " . $_GET["id"];
  if (!$RES = mysql_query($SQL, $linkid)) {
    die("Failure to retrive file metadata");
  }

  if (mysql_num_rows($RES) != 1) {
    die("Not a valid file id!");
  }

  $FileObj = mysql_fetch_object($RES);

  // Pull the list of file inodes
  $SQL = "SELECT id FROM filedata WHERE masterid = " . $_GET["id"] . " order by id";

  if (!$RES = mysql_query($SQL, $linkid)) {
    die("Failure to retrive list of file inodes");
  }

  while ($CUR = mysql_fetch_object($RES)) {
    $nodelist[] = $CUR->id;
  }

  // Send down the header to the client
  Header ( "Content-Type: $FileObj->datatype" );
  Header ( "Content-Length: " . $FileObj->size );
  Header ( "Content-Disposition: attachment; filename=$FileObj->name" );

  // Loop thru and stream the nodes 1 by 1

  for ($Z = 0 ; $Z < count($nodelist) ; $Z++) {
    $SQL = "select filedata from filedata where id = " . $nodelist[$Z];

    if (!$RESX = mysql_query($SQL, $linkid)) {
      die("Failure to retrive file node data");
    }

    $DataObj = mysql_fetch_object($RESX);
    echo $DataObj->filedata;
  }
}
?>

Ok, figured out why it was downloading and not showing the images...

 

Header ( "Content-Disposition: attachment; filename=$FileObj->name" );

 

So now, it's just back to the question on how you all feel about 250,000 images being inserted as blobs and being called from 200 plus domains?

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.