last day (14 days later) » 

6:23 PM
1
A: multer file without extension

Shekhar TyagiHow i upload a file using multer. node code var multer = require('multer'); var fs = require('fs'); var Grid = require('gridfs-stream'); var router = express.Router(); var upload = multer({dest: 'uploads/'}); mongoose.createConnection('mongodb://127.0.0.1/obi'); router.post('/upload', upload....

 
user7495940
do i need Grid?
 
user7495940
well my code was working with the first logic, when i want change filename with the 2 logic it doesnt work :(
 
yes , gridfs-stream is used to store and read files from mongodb.
 
user7495940
i solve it with your help thanks :D
 
user7495940
you know how i can get the image to display on client angular side?
 
6:23 PM
just use the image url . please accept .
 
user7495940
that doesn't work friend can i talk with you on chat»?
 
you can what's appme +918126724591
 
user7495940
don't have, facebook?
 
user7495940
hi, thanks for your patience, but im desperated hehe
 
user7495940
basicly i have a folder in my server called public/upload
 
6:24 PM
ok
 
user7495940
where i save my images with multer
 
what the issue you are facing
 
user7495940
localhost:8080/public/upload/… with this path i can retrive a image
 
user7495940
but in angular side i can't retrive the image, basicly im looping trough a array to pass the image to the users
 
user7495940
but i must change the path there because i need the localhost8080://
 
user7495940
6:25 PM
you understand?
 
user7495940
atm?
 
user7495940
so i do this:
 
i understand
 
user7495940
data[i].foto.img = 'http://localhost:8080/'+data[i].foto.img;
 
user7495940
6:26 PM
but this gives me a error: where the path seems strange
 
you are open the image with the localhost:8080/public/upload/… as you said
right
on node server
 
user7495940
yes it worked
 
user7495940
if i write direclty on my angular with a img src it worked to
 
ok. i understand what issue you are facing
 
user7495940
but i want to add it dynamicly
 
user7495940
6:27 PM
see the error:
303138773bc02d0dfea979d09bf2ae17.jpg:1 GET http://localhost:8081/public/upload/303138773bc02d0dfea979d09bf2ae17.jpg 404 (Not Found)
 
becasue the localhost of angular and node are different.
 
user7495940
exactly
 
user7495940
can't get it directly
 
user7495940
8080 node
 
user7495940
8081 angular
 
user7495940
6:28 PM
why the concat not work?
 
do one thing open the connection information and replace the ip address with you localhost of node
in place of localhost use your ip address like 192.45.23.45
then you can access the image.
is this works
 
user7495940
not working
 
user7495940
that seems not a good idea too this project is for my teacher she should change the ip to see it right ?:)
 
yeah right.
but if you want to work in your local then this is best way.
otherwise you have to upload it on server . purchasing the ip
that's costly
 
user7495940
the concat is not working
 
user7495940
6:36 PM
i just log it
 
how old are you ?
 
user7495940
20 why?
 
user7495940
i did that that didn't work
 
nothing.
can you replace this ip address in place of localhost
you can contact me on my what's app no +91 8126724591
 
user7495940
6:53 PM
i did it
 
user7495940
the for loop i was doing that bad
 
user7495940
what a shame
 
user7495940
thanks for the help
 
user7495940
you still there?
 
Hi
have you solved your ploblem?
 
user7495940
6:56 PM
yes i did, but i have other now, if i don't send a file how can i let it pass in the route?
 
user7495940
my user don't need to pass the file
 
user7495940
just if he want
 
I don't understand. Please raise separate question.
 
user7495940
i am uploading files with multer
 
ok, I see new question
 

last day (14 days later) »