I am attempting to upload a file in my node/express app, and I am getting the following error:
{ [Error: ENOENT, rename \'/tmp/64124a9886fdb03f1faee159bc5337
Have you checked the destination path you are using exists? (maybe you mean app.get('loc') + "/uploads/"
...)
Oddly when this happens (source file exists and destination directory not), the error message you get only points to the source file... So check if that's not the problem.
Remember if you want to move the uploaded file to /a/b/c.txt
, both /a
and /a/b
must already exist.
Also, if you need to move the file to a different partition you will have to use something like this, or you will get a EXDEV
error.
Probably won't help the original poster, but in case somebody else runs into this issue and finds that the source and destination both appear to exist yet are running into this error, hopefully this will help. When I ran into this issue this is the exact problem I found - when I checked, both the source (full path to file) and destination (directory) was present, yet the rename was throwing ENOENT.
In my case the solution was to recognize that I was using the asynchronous version of the directory creation function to create the destination directory. As a result, at the time the rename was attempt the destination directory did not yet exist, but as soon as I checked it had completed and the directory was there. Switching to the synchronous version of directory creation fixed the problem.