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

Uploading the same file with same name overwrites old file #61

Open
safaorhan opened this issue Jul 3, 2016 · 1 comment
Open

Uploading the same file with same name overwrites old file #61

safaorhan opened this issue Jul 3, 2016 · 1 comment

Comments

@safaorhan
Copy link

I uploaded a file name host.jpg for the first time. It saved the file into the folder /public/upload.

The response of calling GET /upload is fine:

[{ "filename": "host.jpg", "filesize": 35706, "creationDate": 1467561753773, "uploaderId": "26c2828d6d9d08a5", "type": "image/jpeg", "id": "370fc11a74c8aa8b" }]

After uploading the same file again (I think) it overwrites the file. There is just one file under /public/upload folder and calling GET /upload shows multiple entries:

[{ "filename": "host.jpg", "filesize": 35706, "creationDate": 1467561753773, "uploaderId": "26c2828d6d9d08a5", "type": "image/jpeg", "id": "370fc11a74c8aa8b" }, { "filename": "host.jpg", "filesize": 35706, "creationDate": 1467561950163, "uploaderId": "26c2828d6d9d08a5", "type": "image/jpeg", "id": "80e90364f3528877" }]

Is it the expected behavior?

@safaorhan safaorhan changed the title Uploading the same file with same name overwrites old file. Uploading the same file with same name overwrites old file Jul 3, 2016
@herOwOw
Copy link

herOwOw commented Jun 23, 2019

3 years from now and having same problem, i just changed the md5 line that rename the files to this:
Date().now() // seems buggy
file.name = md5(new Date().getFullYear() + new Date().getSeconds() + file.name + new Date().getMonth() + new Date().getMinutes() ) + '.' + file.name.split('.').pop();

it worth it to take few minutes read plugin and write your own since this lib using formidable..

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

2 participants