Browse Source

write skin file after writing image

master
poikilos 6 years ago
committed by Jacob Gustafson
parent
commit
135ff80a28
  1. 14
      webapp/server.js

14
webapp/server.js

@ -335,11 +335,13 @@ app.post('/set-skin', function (req, res){
//(OldCoder, 2019) //(OldCoder, 2019)
var directPath = ""; var directPath = "";
var indirectPath = ""; var indirectPath = "";
var destName = "";
var msg = "Uploading..."; var msg = "Uploading...";
form.parse(req, function(err, fields, files) { form.parse(req, function(err, fields, files) {
if (err) next(err); if (err) next(err);
directPath = skinDir + "/player_" + fields.userName + ".png"; destName = destName = "player_" + fields.userName;
indirectPath = skinDir + "/player_" + fields.userName + ".skin"; directPath = skinDir + "/" + destName + ".png";
indirectPath = skinDir + "/" + destName + ".skin";
// TODO: make sure my_file and project_id values are present // TODO: make sure my_file and project_id values are present
if (files.userFile != undefined) { if (files.userFile != undefined) {
var originalPath = files.userFile.path; var originalPath = files.userFile.path;
@ -352,6 +354,13 @@ app.post('/set-skin', function (req, res){
console.log(msg); console.log(msg);
next(err); next(err);
} }
else {
fs.writeFile(indirectPath, destName, function(err, data) {
if (err) console.log(err);
console.log("Successfully wrote " + destName
+ " to "+indirectPath+".");
});
}
res.end(); res.end();
}); });
} }
@ -387,7 +396,6 @@ app.get('/', function (req, res) {
if (req.query.date) selected_date_s = req.query.date if (req.query.date) selected_date_s = req.query.date
if (req.query.msg != undefined) { if (req.query.msg != undefined) {
ret += "<br/>\n"; ret += "<br/>\n";
//ret += "<b>" + querystring.parse(req.query.msg) + "</b><br>\n"; //ret += "<b>" + querystring.parse(req.query.msg) + "</b><br>\n";
// line above causes: // line above causes:
//TypeError: Cannot convert object to primitive value //TypeError: Cannot convert object to primitive value

Loading…
Cancel
Save