2015-01-17 6 views
0
에서 대상 경로에 저장되지 않습니다 난 그냥 업로드하고, 나는 그 후 나는 Error: EXDEV, rename 'c:\Users\abdul\AppData\Local\Temp\3348-qiy7kl.jpg'

업로드 된 이미지는 Node.js를

의이 유형을 얻고, req.files에 의해 파일의 상세 정보를 얻고 내 public/images 폴더에 이미지를 저장하려고

여기

stuff

app.post('/upload',function(req,res){ 
    var tmp_path = req.files.file.path; 
    var target_path = './public/images/' + req.files.file.originalFilename; 
    fs.rename(tmp_path, target_path, function(err) { 
     if (err) throw err; 
     fs.unlink(tmp_path, function() { 
      if (err) throw err; 
      res.send('File uploaded to: ' + target_path + ' - ' + req.files.file.size + ' bytes'); 
     }); 
    }); 
    }) 
}; 

어떤 몸이 어떤 제안을 제공하거나 내가 처리 할 수 ​​있도록 나에게 어떤 참조를 줄 수 내입니까?

답변

0

나를 위해 작동이 하나 개

console.log("File Name " + req.files.file.name); 
    console.log("File Path " + req.files.file.path); 

    fs.readFile(req.files.file.path, function (err, data) { 
     var newPath = "public/images/" + req.files.file.originalFilename; 
     console.log(newPath); 
     /// write file to uploads/fullsize folder 
     fs.writeFile(newPath, data, function (err) { 
      /// let's see it 
     }); 
+0

헤이 @Ali 덕분에, 시도 – abdulbarik

관련 문제