728x90
    
    
  반응형
    
    
    
  업로드 코드에서 아래와 같은 에러가 발생.
| 1 2 3 | Error: ENOENT: no such file or directory, rename      '/var/folders/9n/785gcy3j5nb5hkgldym9r6x00000gn/T/upload_bf35eaa00eb98c26f00ad6e50acd5699'      -> 'tmp/test.png' | cs | 
그렇다면 해당 소스를 다시보자.
| 1 2 3 4 5 6 7 8 9 10 11 12 |   var form = new formidable.IncomingForm();   console.log("about to parse");   form.parse(request, function(error, fields, files) {     console.log("parsing done");     fs.renameSync(files.upload.path, "tmp/test.png");     response.writeHead(200, {"Content-Type": "text/html"});     response.write("received image:<br/>");     response.write("<img src='/show' />");     response.end();   }); | cs | 
renameSync에서 저 경로에 제대로 작성된 경로일까?
절대경로라면 /tmp/test.png 로 작성을 했어야 했다.
아주 사소한 실수인 것이다.
| 1 2 3 4 5 6 7 8 |   form.parse(request, function(error, fields, files) {     console.log("parsing done");     fs.renameSync(files.upload.path, "/tmp/test.png");     response.writeHead(200, {"Content-Type": "text/html"});     response.write("received image:<br/>");     response.write("<img src='/show' />");     response.end();   }); | cs | 
제대로 수정하고 실행하면 정상적으로 업로드가 된다.
실제 경로에서 해당 파일도 찾아보았다.
| 1 2 3 4 5 6 7 8 9 | User:/ () User:/ () cd /tmp User:tmp () ls -al total 32 drwxrwxrwt  12 root        wheel   384  4 16 13:56 . drwxr-xr-x   6 root        wheel   192 11 28 11:24 .. * * * 생략 * * * -rw-r--r--   1 User      staff  9166  4 16 13:56 test.png User:tmp () | cs | 
728x90
    
    
  반응형
    
    
    
  'Server' 카테고리의 다른 글
| AWS API Gateway + Lambda를 이용한 우회용 API 만들기 (0) | 2023.08.16 | 
|---|---|
| Webpack dev server를 첫 가동하기 위한 여정 (0) | 2018.04.30 | 
| EC2에서 Telnet이 작동하지 않을 때 (1) | 2018.04.12 | 
| [Node.js] UNABLE_TO_GET_ISSUER_CERT_LOCALLY Error (1) | 2018.04.09 | 

Comment