Odoo Help


Cannot get file upload by "environ" in my page using httprequest

Nguyễn Xuân Huy
on 6/4/14, 11:54 PM 1,533 views

Hi all!

I create "my page" using httprequest to upload file, but it cannot get file upload.

page load forever when run to line code :"fs = cgi.FieldStorage(fp=fp, environ=environ)"

Any one help me.

Thank very must!

And this is my code:

import glob
import itertools
import json
import operator
import os

from mako.template import Template
from openerp.modules import module

from openerp.addons.web.controllers.main import module_topological_sort
from openerp.addons.web import http

import cgi, os
import cgitb; cgitb.enable()
from httplib import HTTP
import urlparse

temp = """<html><body>
<form method="post" action="/sa/save">
<p>File: <input type="file" name="myfile"></p>
<p><input type="submit" value="Upload"></p>

class simplecontroller(http.Controller):
_cp_path = '/sa'

def index(self, req, **kwargs):
return temp

def save(self, req, **kwargs):
environ = req.httprequest.environ
fs = cgi.FieldStorage(fp=fp, environ=environ)# delay forever when run this line
f = fs.getfirst('myfile')
filepath =req.params.get('myfile')
fout = open(filepath,'w') 

return "upload successfully"


up, help me !

Nguyễn Xuân Huy
on 6/10/14, 6:34 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/4/14, 11:54 PM
Seen: 1533 times
Last updated: 3/16/15, 8:10 AM