Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one file is uploaded several times #64

Open
atongvicente opened this issue Nov 21, 2014 · 0 comments
Open

one file is uploaded several times #64

atongvicente opened this issue Nov 21, 2014 · 0 comments

Comments

@atongvicente
Copy link

Hello

I have a weird problem, I'm working on creating a one interface to permit only load one file, it works well when I load the file for the first time, but when I load another file after deleting the previous file, this new file is uploaded twice, and then if I closed the view and open again to load a new file, the file is uploaded three times, I'm using this code to upload in the server.

app.use('/upload', function(request, response, next){
upload.fileHandler({
uploadDir: function(){
return __dirname + '/site/public/uploads/' + request.session.login;
},
uploadUrl: function(){
return '/site/uploads/' + request.session.login;
}
})(request, response, next);
upload.on('begin', function(fileInfo){
logger.debug("starting loading a file");
var ext = fileInfo.name.substr(fileInfo.name.lastIndexOf('.') + 1);
var newFile = shortId.generate() + '.' + ext;
request.session.newFile = newFile;
logger.debug("file uploaded " + request.session.newFile + " - " + newFile);
fileInfo.name = newFile;
});
upload.on('end', function(fileInfo){
logger.debug('file uploaded ' + fileInfo.name);
});
});

I would appreciate any suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant