Hey,

I have in my controller:
   post_save=SQLFORM(db.ads)
    if post_save.accepts(request.vars,session,formname=None):
      import md5, datetime, os
      _file_name=md5.new(str(datetime.datetime.now())).hexdigest()
+".gif"
      _folder='%(folder)suploads/adverts/'%{'folder': request.folder}
      main_token=md5.new(str(datetime.datetime.now())).hexdigest()
      if not os.path.exists(_folder):
         os.makedirs('%sfile'%(_folder))
      file = open('%s%s'%(_folder,_file_name), 'wb')
      file.write(request.vars.file.file.read())
      file.close
      _new_ad=db.ads.insert(
        affiliate_id=request.vars.affiliate_id,
        web_site_id=request.vars.web_site_id,
        ad_section_id=request.vars.ad_section_id,
        category_id=request.vars.category_id,
        ad_link=request.vars.ad_link,
        ad_image=_file_name
      )
      db.ads_sub_categories.insert(
        ads=_new_ad,
        sub_categories=request.vars.sub_category_id
      )

The html for my file upload is <input type="file" name="file"
id="ads_ad_codes" class="string"/>

But for some reason I'm getting returned this error:

AttributeError: 'str' object has no attribute 'file'

Any ideas?

Many thanks in advance.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to