php - ZF2 - Display image in view based on full path -


i have managed upload image file in zf2 , store full path in database. path looks this:

/home/ubuntu/netbeansprojects/project/data/upload/event_5554a7b600c0f.jpg

project structure zend skeleton application:

project data upload event_5554a7b600c0f.jpg module public

in view call:

     <img src="<?php echo $event->getimage(); ?>" class="img-thumbnail" alt="<?php echo $event->gettitle(); ?>" width="304" height="236"> </td> 

$event->getimage() return full file location stated earlier.

if store same image in project public img upload event_5554a7b600c0f.jpg

and store /img/upload/event_5554a7b600c0f.jpg path works.

i have 2 question: 1. policy, store uploaded image files in publi/img folder or in top level data/uploads folder? 2. if better policy store files in data/uploads how can display image?

thank you!

i have created module htimgmodule doing image manipulation in zend framework 2.

here example output image:

namespace applicaton\controller;  use zend\mvc\controller\abstractactioncontroller; use htimgmodule\view\model\imagemodel;  class mycontroller extends abstractactioncontroller {     public function displayimageaction()     {         return new imagemodel('path/to/image');     } } 

so, not absolutely necessary store images in public folder. but, there performance penalty. fortunately, htimgmodule flexible enough cache image web root cached image served directly file system. take @ docs of htimgmodule.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -