picture contest

/*Define dependencies.*/
var express=require("express");
var multer  = require('multer');
var mongoose= require ('mongoose');
var app=express();
var done=false;
/*Configure the multer.*/
app.use(multer({ dest: './uploads/',
 rename: function (fieldname, filename) {
    return filename+Date.now();
onFileUploadStart: function (file) {
  console.log(file.originalname + ' is starting ...')
onFileUploadComplete: function (file) {
  console.log(file.fieldname + ' uploaded to  ' + file.path)
// routes
    res.end("File upload complete.");
// server
    console.log("listening on port 3000");
HTML file
<form id ="uploadForm" enctype="multipart/form-data" action =  "/api/photo"method= "post"
> <input type="file" name="userPhoto" /> <input type="submit" value="Upload Image" name="submit"> </form> 

Open in new window

what i need is how to query each image and server them to my clients every client sees a specifit image, and also get each image in a link such as localhost//3000/users/photos/234  so they can share links to thier images to recieve comments from friends etc as u can see i'm a newbie here thanks
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
A 'localhost' link can not be used from another computer.  'localhost' by definition is on the 'local' computer, the one that you are using.  You need an IP address or host name for people to access your page remotely.
princevladAuthor Commented:
thanks am still building on my computer so that was just an example, my main issue is to dynamically serve static files (images) to users.  i created an fs.readsync  to read all uploaded file and load them to my database but i want something like this
a url that would link everyone to a particular image on my site
just like a you tube video link etc
Julian HansenCommented:
Trying to understand what the problem is?

I am guessing that this is a Node.js / Express.js question - you are asking how to pick up the URL and link that to a specific static resource on the server?

Is your question about how to parse the link or how to return the image?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

princevladAuthor Commented:
yes how to parse the link and return the image and yes is a node.js project

the attachment contains the fool upload code
Julian HansenCommented:
What attachment?

Trying to understand the relevance of the upload code to the problem at hand. As I understand it the upload part works and the file is saved somewhere on your server file system, yes?

If so you are now wanting a method to parse a link to that file and return the file - is that correct?

It sounds like you need to use the methods described here


and specifically here

princevladAuthor Commented:
i was able to render a photo via url params but the url affects other buttons on my site example

it renders the photo in an html page but  when i click on VOTE or another button on the page it shows

cannot post photo/vote/vote
Julian HansenCommented:
That is because of relative paths.

You need to make your links absolute otherwise a link to
<a href="vote"> ...
On page

Will translate to http://server/photo/vote/vote

You have to do
<a href="http://server/photo/vote"> ...

Open in new window

Another (less desirable) option is to use the base tag like so
<base href="http://server" />

Open in new window

This will then prefix all relative links with the URL specified in the base ref tag.

There are some good reasons why this is not a desirable solution but it is valid and in will work.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.