Fixe Image Upload #1
All checks were successful
Neutral/pipeline/head This commit looks good

This commit is contained in:
Raphix
2023-03-23 19:08:38 +01:00
parent 7877729100
commit 493b6973c5
5 changed files with 7 additions and 12 deletions

View File

@ -38,8 +38,6 @@ router.post("/", function(req, res, next) {
const image = req.files.apic
console.log("test")
if(req.headers.uploadforuser != null) {
if(check.permLevel == 4) {
@ -48,7 +46,8 @@ router.post("/", function(req, res, next) {
var uploadPath = "";
var uploadDir = __dirname.replace("routes","public" + path.sep + "images" + path.sep + "userspics" + path.sep)
if(req.files.apic.mimetype == "image/png") {
uploadPath = req.headers.uploadforuser + ".png"
@ -59,7 +58,7 @@ router.post("/", function(req, res, next) {
uploadPath = req.headers.uploadforuser+ ".jpg"
}
image.mv(uploadPath, function(err) {
image.mv(__dirname + path.sep + uploadPath, function(err) {
if(err) {
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
console.log(err)
@ -176,7 +175,7 @@ router.post("/", function(req, res, next) {
uploadPath = ntr.checkToken(req, res).name + ".jpg"
}
image.mv(uploadPath, function(err) {
image.mv(__dirname + path.sep + uploadPath, function(err) {
if(err) {
res.send({"result":"success", "content": "La photo de profil n'a pas pu être chargé."})
console.log(err)