ArthurGoelzer

Untitled

Jul 24th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. router.post('/tagimg', authenticator.isAuthenticated, function (request, response) {
  2.     if (isLoggedIn(request, response, true)) {
  3.         //console.log(request);
  4.         var form = new formidable.IncomingForm();
  5.         form.uploadDir = app.config.media_folder + '\\akmedia\\tags\\';
  6.         form.parse(request, (err, fields, files) => {
  7.             if (files.pictureFile &&  fields.lastId) {
  8.                 console.log('Changing:  ' + fields.lastId);
  9.                 var pictureFile = files.pictureFile;
  10.                 var oldpath = pictureFile.path;
  11.                 var newpath = app.config.media_folder + '\\akmedia\\tags\\' + fields.lastId + '.jpg';
  12.                 fs.rename(oldpath, newpath, (err) => {
  13.                     if (!err) {
  14.                         response.end('{"success" : "Updated Successfully", "status" : 200}');
  15.                     } else {
  16.                         console.log(err);
  17.                         response.end('{"error" : "toma no cu", "status" : 500}');
  18.                     }
  19.                 })
  20.             } else {
  21.                 console.log('fuck');
  22.             }
  23.         });
  24.     } else {
  25.         response.end('{"error" : "toma no cu", "status" : 500}');
  26.     }
  27. });
Add Comment
Please, Sign In to add comment