Error: ENOENT: no such file or directory, open ‘E:\Program Files\nodejs\tmp\upload_38b32f25bc984333c

Look at the picture first:

The main reason for this problem is that the files you are uploading are not in the same folder
So put the folder TMP and the running JS files in the same directory, as shown in the figure below:

Then the path is changed. The first path I wrote was fs.readfile (“/ TMP /test.png”…) There is no problem changing “/ TMP /test.png” to “./ TMP /test.png”
Fs. ReadFile (“./TMP/test. The PNG “, “binary”, function (the error, the file) {
if (error) {
response. WriteHead (500, {” content-type “:” text/plain “});
response. Write (error + “\ n”);
the response. The end ();
} else {
response. WriteHead (200, {” content-type “:” image/PNG} “);
response. Write (file, “binary”);
the response. The end ();


Read More: