dpd-fileupload
dpd-fileupload copied to clipboard
Uploading the same file with same name overwrites old file
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?
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..