i use this code to specify whether or not a file exists:
if(fs.exists('../../upload/images/book/2.jpg')){
console.log("yes the file exist");
} else{
console.log("there is no file");
}
While the file is there, it always says it does not exist(there is no file)
i use fs.stat(...)
too , but again it gives the result (there is no file)
Folder structure:
root_app
--------|.tmp
--------|api
------------|controllers
------------------------|BookContoller.js (My code run from here)
--------|...(And the rest of the folders)
--------|upload
---------------|images
----------------------|book
---------------------------|2.jpg
thank you
My problem was solved.
Apparently, we should use fs.accessSync() OR fs.access() instead of fs.exists()
Check out this link
This procedure can also be performed:
Thanks to everyone who helped me