我的要求是將文件/圖像從現有文件夾複製到另一個文件夾。我怎樣才能用帆JS 實現它我試着用這樣的:我們如何使用Sails js或Node js複製或移動圖像/文件
var imagePath = photoName; //image source path
var proImagePath = './assets/images/profilePics/'; //image destination
var stream = fs.createReadStream(imagePath);
stream.on('error', function (error)
\t {
\t \t console.log("Caught", error);
\t });
stream.on('readable', function()
\t {
\t \t stream.read();
\t \t var desti = fs.createWriteStream(proImagePath); \t \t //desti
\t \t stream.pipe(desti);
\t \t stream.on('end',function() {
stream.close();
\t \t return res.json(200, {status: 1, message: 'Success.'});
\t });
但隨着安慰的錯誤:
Caught { [Error: ENOENT, open 'http://192.168.1.64:9002/images/userimages/sijobhai/91121438-7219-4c0f-b27c-516b289614a2.jpg']
errno: 34,
code: 'ENOENT',
path: 'http://192.168.1.64:9002/images/userimages/sijobhai/91121438-7219-4c0f-b27c-516b289614a2.jpg' }
看看節點fs https://nodejs.org/api/fs.html –
不會出現,你甚至沒有嘗試過這個網頁搜索。在這裏問問題之前,你需要做基礎研究 – charlietfl