545097 (1) [Avatar] Offline
#1
My assets folder :

assets  
     | images  
            | media  
                  | book  
                        | pictures  

i want to create new book when i upload book picture in above path, But when i try to show this image in view, the image can not be displayed and there is no error either.
my code is:

//BookController
create: function (request, response, next) {
var title = request.body.title;
var subject = request.body.subject;
var brief = request.body.brief;
var author = request.body.author;
var origin_pic_name = null;

request.file('pic').upload({
  dirname: '../../assets/images/media/book/pictures/',
},function (err, file) {
  if(err) console.log(err);
  origin_pic_name = file[0]['fd'].split('\\').reverse()[0] ;

  Book.create({title:title,subject:subject,brief:brief,author:author,pic:origin_pic_name}).exec(function (err) {
    if(err) response.end(500, {error: 'Database Error'});
    response.redirect('/');
  });

});},  

index : function (request, response, next) {
Book.find({}).exec(function (err, books) {
  if(err) response.end(500, {error: 'Database Error'});
  response.view('book/index', {books:books});
});},  

//my index.ejs
<ol>
<% books.forEach(function (value) {%>
  <h3><li> <%= value.title %></li></h3>
  <ul><%= value.author %></ul>
  <ul><%= value.subject %></ul>
  <ul><%= value.brief %></ul>
  <ul><img src="/images/media/book/pictures/<%= value.pic %>"/></ul>
<% })%>
</ol>

thank you