I created an NodeJS App using Express and I uploaded my App on AppFog, the only problem is that I have a file upload form in my App in order to upload some photos for the App (for my "Creation" table). It works in local but on AppFog it doesn't work, maybe AppFog have locked the upload files... I don't know exactly what am I supposed to do... My CHMOD directory is "0777".
(sorry for my english, I come from Europe)
My view:
form.admin(action='/creations/save', method='post', enctype='multipart/form-data')
div
label(for='title') Title
input(type='text', name='title', placeholder='Title...')
div
label(for='thumbnail') Thumbnail
input(type='file', name='thumbnail')
div
label(for='moodboard') Moodboard
input(type='file', name='moodboard')
input(type='submit', value='Save')
input(type='reset', value='Cancel')
My controller:
var saveFile = function(file, folder){
var file_tmp = file.path;
var file_name = file.name;
var file_type = file.type;
var file = './uploads/'+folder+'/'+file_name;
console.log(file);
fs.rename(file_tmp, file, function(err){
if( err ) console.log(err);
});
}
exports.save = function(req, res) {
saveFile(req.files.thumbnail, 'thumbnails');
saveFile(req.files.moodboard, 'moodboards');
global.db.Creation.create({
title: req.body.title,
description: req.body.description,
location: req.body.location,
date: req.body.date,
thumbnail: req.files.thumbnail.name,
moodboard: req.files.moodboard.name
}).success( function(creation){
res.redirect('/glovebox');
});
}
Anthony