<commit_before>var profile = require("../profileimage.json");
var eventTest = require("../eventTest.json");

var multer = require('multer');
var storage =   multer.diskStorage({
  destination: function (req, file, callback) {
    callback(null, './public/uploads');
  },
  filename: function (req, file, callback) {
    callback(null, file.originalname);
  }
});

var upload = multer({ storage : storage}).single('userPhoto');


exports.viewGallery = function(req, res){
	res.render('gallery', eventTest);
};

exports.addPhoto = function(req,res){
	 upload(req,res,function(err) {
        if(err) {
            console.log(err);
            return res.end("Error uploading file.");
        }
        var origName = req.body.group;
        for(var i = 0; i < eventTest.groups2.length; i++) {
  			  if(eventTest["groups2"][i].group == origName) {
    				var newTarget = "{\"image\" : \"./uploads/"+req.file.originalname+"\"}";
    				eventTest["groups2"][i]["imageURL"].push(JSON.parse(newTarget));
    				break;
  			  }
  		  }       
		    res.redirect('gallery'); 
    });
};<commit_msg>still trying to find out why it wont push image<commit_after>var profile = require("../profileimage.json");
var eventTest = require("../eventTest.json");

var multer = require('multer');
var storage =   multer.diskStorage({
  destination: function (req, file, callback) {
    callback(null, './public/uploads');
  },
  filename: function (req, file, callback) {
    callback(null, file.originalname);
  }
});

var upload = multer({ storage : storage}).single('userPhoto');


exports.viewGallery = function(req, res){
	res.render('gallery', eventTest);
};

exports.addPhoto = function(req,res){
	 upload(req,res,function(err) {
        if(err) {
            console.log("There appears to be an error: " + err);
            return res.end("Error uploading file.");
        }
        var origName = req.body.group;
        for(var i = 0; i < eventTest.groups2.length; i++) {
  			  if(eventTest["groups2"][i].group == origName) {
    				var newTarget = "{\"image\" : \"./uploads/"+req.file.originalname+"\"}";
    				eventTest["groups2"][i]["imageURL"].push(JSON.parse(newTarget));
    				break;
  			  }
  		  }       
		    res.redirect('gallery'); 
    });
};
{'fraction_non_alphanumeric': 0.18004434589800444, 'fraction_numerical': 0.003547671840354767, 'mean_word_length': 3.01423487544484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1500684', 'n_tokens_mistral': 763, 'n_tokens_neox': 716, 'n_words': 141}