0
我想删除客户端中的文件夹/文件(使用javascript/Jquery/AngularJS1)。我正在搜索,最后我使用Node.js它可以在Sitepoint链接中完成。现在我没有得到如何用任何一种语言设置Node.js fs(文件系统)(首选语言是AngularJS1)。寻找解决方案。 在此先感谢。如何将Node.js文件系统设置为离子项目
我想删除客户端中的文件夹/文件(使用javascript/Jquery/AngularJS1)。我正在搜索,最后我使用Node.js它可以在Sitepoint链接中完成。现在我没有得到如何用任何一种语言设置Node.js fs(文件系统)(首选语言是AngularJS1)。寻找解决方案。 在此先感谢。如何将Node.js文件系统设置为离子项目
var express = require('express');
var app = express();
var fs = require("fs");
var bodyParser = require('body-parser')
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.get('*', function (req, res) {
console.log(req.path);
var path = req.path;
if(req.path == '/'){
res.sendFile(__dirname + "/" + "index.html");
}else
{
res.sendFile(__dirname + req.path);
}
});
app.post('/app',function (req, res) {
console.log(req.body)
var action = req.body.action;
var data = req.body.data;
var fname = req.body.fileName;
switch(action) {
case 'upLoad':
function decodeBase64Image(dataString) {
var matches = dataString.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/),
response = {};
if (matches.length !== 3) {
return new Error('Invalid input string');
}
response.type = matches[1];
response.data = new Buffer(matches[2], 'base64');
return response;
};
var imageBuffer = decodeBase64Image(data);
var newPath = __dirname + "/app/images/" + fname;
fs.writeFile(newPath, imageBuffer.data, function(err) {
res.send({confirm : "uploaded" , filename:fname });
});
default:
}
})
var server = app.listen(8080, function() {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
})
Hi this is Application Folder which i had used.
在其中i包含的node.js模块和装入应用程序这Server.js文件。
您无法删除客户端的文件夹/文件,想象一下如果可以这样做会发生什么 – madalinivascu
使用Node.js fs我们可以做到这一点。请访问https://www.sitepoint.com/accessing-the-file-system-in-node-js/一次 –
使用node.js您可以在服务器端而不是客户端执行 – madalinivascu