Dear Ceej I would like to upload to a form , from a python script. (Client side)
Web2py do no thave upload (as client) rite? Thanks for reply anyways. Regards, Phyo. On Thu, Nov 13, 2008 at 7:15 PM, ceej <[EMAIL PROTECTED]> wrote: > > Phyo, > > To get the data from the form that's submitted you can to > request.vars.file.file.read(): > > And to write it to uploads you can do something like > > _folder='%(folder)suploads/'%{'folder': request.folder} > main_token=md5.new(str(datetime.datetime.now > ())).hexdigest() > if not os.path.exists(_folder): > os.makedirs('%sfile'%(_folder)) > file = open('%syou_can_make_a_name.jpg'%(_folder), 'wb') > file.write(request.vars.file.file.read()) > file.close > > On Nov 13, 10:33 am, "Phyo Arkar" <[EMAIL PROTECTED]> wrote: > > Dear All; > > > > How can i upload multipart form data files in python (web2py?) > > > > I cannot do it with > > > > urllib.urlencode > > urllib2.urlopen(url,data) > > > > Files will not be uploaded , just urls will b posted ..(server backend is > > php) > > > > def upload(torrentfile,nfofile,subgenre='Minimal',type=10): > > nfo_file=file(nfofile) > > torrent_file=file(torrentfile) > > data = {'nfo': nfo_file, > > 'desc': "", > > 'file': torrent_file, > > 'type': type, > > 'subgenre' : subgenre > > } > > uldata =urllib.urlencode(data) > > req = urllib2.Request(upload_url,uldata) > > resp = urllib2.urlopen(req) > > result = resp.read() > > print result > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---