Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File uploading not working #125

Open
Antonded opened this issue Nov 14, 2014 · 1 comment
Open

File uploading not working #125

Antonded opened this issue Nov 14, 2014 · 1 comment

Comments

@Antonded
Copy link

My schema is
var NewsItemSchema = new Schema({
title: {type: String, required: true},
date: {type: Date, required: true, default: new Date()},
subtitle: {type: String, required: false},
images: {type: Schema.Types.File, upload_to: __dirname + '/../public/uploads/'},
text:{type: String, required: true},
state:{type: String, enum: ['current', 'archive', 'draft', 'personal']}
});

but nothing happens, in browser's POST request is no field containing my file. In Webstorm debugger i can't see that FileField pre_precess function works, but nothing happens. my App.js:

'use strict';

var mongoose = require('./models/mongoose').mongoose;

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var log = require('./libs/log')(module);
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var passport = require('passport');
var config = require('./libs/config');
var session = require('express-session');
var methodOverride = require('method-override');
var multer = require('multer');
var MongoStore = require('connect-mongo')(session);

require('./libs/passport.js');

var app = express();
var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(cookieParser());
app.use(methodOverride());
app.use(bodyParser.json());
app.use(multer({ dest: __dirname + '/private/uploads/'}));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));

var formage = require('formage').init(app, express, mongoose.models, {
title: 'Экономическая олимпиада имени Кондратьева',
root: '/formage',
default_section: 'main',
admin_users_gui: true
});

app.use(session({
secret: "hidden",
proxy: true,
resave: true,
saveUninitialized: true,
store:new MongoStore({db: 'kondrat-olymp'})
}));

app.use(passport.initialize());
app.use(passport.session());

and forage can't find socket.io.js, i've added it manually but it can't establish connection

@Antonded
Copy link
Author

I've 3.2.21 installed from git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant