how to output image file from database drupal 7? I have created testing module that will upload image and outputting it to my page. but, I can't seem to output my image file from my database. here's my code


function database_ex_menu() {
  $items = array();
  $items['database-ex'] = array(
    'title' => 'My Database Form',
    'type' => MENU_NORMAL_ITEM,
    'access arguments' => array('submit database_ex'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('database_ex_form'),
  );
  return $items;
}

function database_ex_form($form, $form_state) {
  $form['myimage'] = array(
    '#type' => 'file',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add item'),
  );
  return $form;
}


function database_ex_form_submit($form, $form_state) {
  $fe_id = db_insert('example')
    ->fields(array(
      'myimage' => $form_state['values']['myimage'],
    ))
    ->execute();

  drupal_set_message(t('Your entry has been added'));
}

//This function supposedly will output my image file inside a div.

function database_ex_submission(){
  //What to do From here!
}
Firstly save image to your server and then you can output the image.

You can save image by using file_save_upload(). 


  file_save_upload : Saves a file upload to a new location.


$file = file_save_upload('myimage',array(), 'public://');


Get fileid(fid) of the image

$fid=$file-&gt;fid;


And then save this $fid to your database.

After it get fid from database

  $upload_record = file_load($fid);
  $url = $upload_record-&gt;uri;

  $render_image = theme(
    'image_style', 
    array(
      'style_name' =&gt; 'Style_name', 
      'path' =&gt; $url, 
      'getsize' =&gt; TRUE, 
      'attributes' =&gt; array(
        'width' =&gt; '250', 
        'height' =&gt; '162')
      )
    );


Now print $render_image variable where you want to display image.