Embed presentation
Download as KEY, PPTX









![www.your-domain.com/images/tron.jpg
( assuming .htaccess is redirecting within folder )
// Get Filename
$slug = $_SERVER[‘REQUEST_URI’];
// Define Database
$db = $m->$options['db_name'];
// Get GridFS
$grid = $db->getGridFS();
// Get Image
$image = $grid->findOne(
array("name" => $slug)
);
// Display Image
header('Content-type: '.$image->file['type']);
echo $image->getBytes();](https://image.slidesharecdn.com/gridfs-120504013831-phpapp01/85/Serving-Images-with-GridFS-10-320.jpg)


The document discusses storing and serving images using GridFS instead of traditional file systems, highlighting the limitations of file systems such as poor scaling and lack of metadata. It emphasizes GridFS's advantages, including automatic load balancing and backup through replica sets. An example PHP code snippet is provided to demonstrate how to retrieve and display images stored in GridFS.









![www.your-domain.com/images/tron.jpg
( assuming .htaccess is redirecting within folder )
// Get Filename
$slug = $_SERVER[‘REQUEST_URI’];
// Define Database
$db = $m->$options['db_name'];
// Get GridFS
$grid = $db->getGridFS();
// Get Image
$image = $grid->findOne(
array("name" => $slug)
);
// Display Image
header('Content-type: '.$image->file['type']);
echo $image->getBytes();](https://image.slidesharecdn.com/gridfs-120504013831-phpapp01/85/Serving-Images-with-GridFS-10-320.jpg)
