valum文件上传器重置expressjs中的会话

时间:2013-11-03 14:33:48

标签: express appfog valums-file-uploader

我正在尝试使用valum的ajax上传来上传文件。在服务器端我使用expressjs,它是一个后置动词。在服务器端,它将req.session.id作为json发回(发送当前的sessionid)。但是在上传请求结束时,会话cookie被更改(会话在服务器上重置/所有保存变量都消失了)。我不确定发生了什么。 这种情况发生在APPFOG不在本地主机上。

app.post '/photo/upload', (req,res)->
  res.json {id: req.session.id}
前端

            uploader = new qq.FileUploader
                        element: document.getElementById('file-uploader')
                        action: '/photo/upload'
                        allowedExtensions: [ "jpg", "jpeg", "png", "gif" ]
                        sizeLimit: 0
                        minSizeLimit: 0
                        onSubmit: (id, filename) ->  
                        onComplete: (id, filename, responseJSON) ->
                            photoId = responseJSON.id

这是普通的快递应用

Module dependencies.

express = require("express")
http = require("http")
path = require("path")
global.app = express()

app.set "port", process.env.PORT or 3000
app.set "views", __dirname + "/views"
app.set "view engine", "jade"
app.use express.favicon()
app.use express.logger("dev")
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.cookieParser("your secret here")
app.use express.session()
app.use app.router
app.use require("stylus").middleware(__dirname + "/public")
app.use express.static(path.join(__dirname, "public"))


app.use express.errorHandler()  if "development" is app.get("env")


routes = require("./routes")

http.createServer(app).listen app.get("port"), ->
  console.log "Express server listening on port " + app.get("port")

0 个答案:

没有答案