Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:33:27+00:00 2026-06-04T07:33:27+00:00

I am currently developing a script that requires images stored into Mongo with GridFS,

  • 0

I am currently developing a script that requires images stored into Mongo with GridFS, although when the files are being retrieved (with a php header) the width=”” and height=”” HTML is already placed into the display, is there any way I change this or store it within Mongo/GridFS?

// get GridFS files collection
  $grid = $db->getGridFS();

  // retrieve file from collection
  $file = $grid->findOne(array('_id' => new MongoId('4fb437dbee3c471b1f000001')));

  // send headers and file data
  header('Content-Type: image');
  echo $file->getBytes();
  exit;  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:33:28+00:00Added an answer on June 4, 2026 at 7:33 am

    PHP won’t add those width and height tags itself. It might be something that your browser adds for you though so please check what is actually send across the wire!

    In any case, when you store a file in GridFS, you can set extra meta data:

    $grid->storeFile($filename, array("height" => 42, "width" => 38));
    

    In order to make use of this information, you will have to do a separate query that queries this, and then injects it into your HTML code. A query to get the meta data can be with:

    $file = $grid->findOne(array('_id' => new MongoId('4fb437dbee3c471b1f000001')));
    var_dump( $file );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently developing a PHP framework and have ran into my first problem. I need
I'm currently developing a script that takes a Word document, opens it up in
I'm currently developing a script that takes a message, splits it apart every 100
I'm currently developing a script for a map in COD4. I think that the
I'm currently developing what is more or less a script that needs to get
I'm currently developing a website that will make use of PHP scripts and I'd
I'm currently developing a Safari extension that uses an injected script to further inject
I am currently developing a responsive website. I've developed a jquery script that changes
I am currently developing a very simple script in AutoHotKey, but it involves using
I'm currently developing a widget that can be embedded within a page. However, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.