hi,

I want save one image in dinamic directory  web2py, but ai not using 
SQLFORM, 

When i do upload the image i recieve in controller C:/FAKEPATH/imagename

how do i handle this path or other upload ?

sorry my inglish.

look my code:

View:

<form id="insertuser" novalidate>
 <div class="col-md-12 col-sm-12 col-xs-12">
  <div class="col-md-3 col-sm-12 col-xs-12">
    <div class="form-group">
  <label for="cadfirstname">Primeiro Nome</label>
  <input type="text" class="form-control " id="cadfirstname" 
placeholder="Primeiro Nome">
                       
    </div>
   </div>
   <div class="col-md-3 col-sm-12 col-xs-12">
    <div class="form-group">
<label for="cadsecondname">Segundo Nome</label>
<input type="text" class="form-control " id="cadsecondname" 
placeholder="Segundo Nome">
    </div>
  </div>
   <div class="col-md-3 col-sm-12 col-xs-12" >
    <div class="form-group">
<label for="cademail">E-mail</label>
<input type="email" class="form-control " id="cademail" placeholder="Email" 
required="required" >
    </div> 
  </div>
   <div class="col-md-3 col-sm-12 col-xs-12">
    <div class="form-group">
<label for="cadpass">Senha</label>
<input type="password" class="form-control " id="cadpassuser" 
placeholder="Senha">
    </div> 
   </div>
 </div>
 <br />
 <div class="col-md-12 col-sm-12 col-xs-12">
  <input id="image_title" name="text" type="text" /> 
  <input id="image_file" name="file" type="file" /> 
  <div class="form-group">
  <button id="btn-user" type="button" class="btn btn-lg btn-primary fa 
fa-floppy-o pull-right"> Cadastrar</button>
   <button id="btn-limpar" type="reset" class="btn btn-lg btn-primary fa 
fa-eraser pull-right" arial-hidden="true">  Limpar</button>
  </div>
 </div>


<!-- AJAX -->


$("#btn-user").click(function () {
//ADD show Modal de loading 
//$("#loading").modal('show');
$("#loading").removeClass('hide') 
var firstname = $('#cadfirstname').val();
var lastname = $('#cadsecondname').val();
var email = $('#cademail').val();
var passuser = $('#cadpassuser').val();
var image = $('#image_file').val();

alert(form_vars);
$.getJSON("{{=URL(c='manager', 
f='newuser.json')}}",{firstname,lastname,email,passuser,image}, 
 function(result){
atualizaGrid();
$("#retorno").removeClass('hide');
                              
//Atualiza combobox
atualizaCombobox();
//RESETAR FORMULARIO AO INSERIR
$('#insertuser').each (function(){
  this.reset();
});

//$("#loading").modal('hide');
$("#loading").addClass('hide')                             
 });   

});


CONTROLLER:

@auth.requires_login()
def newuser(): 
  import json 
  import gluon.contrib.simplejson
  
  #parametros de entrada da grid
  firstname = request.vars['firstname']
  lastname = request.vars['lastname']
  email = request.vars['email']
  passuser = request.vars['passuser']
  image = request.vars['image']
  
  # Query
  db.auth_user.insert(first_name=firstname, last_name=lastname, 
email=email, password = db.auth_user.password.validate(passuser)[0] , image 
= image, emp_id = db.auth_user[auth.user_id].emp_id)
  
  userid = db(db.auth_user).select(db.auth_user.id).last()

  db.auth_membership.insert(user_id=userid,group_id=3)
  
  
  data =  db(db.auth_user).select(db.auth_user.id,db.auth_user.first_name, 
db.auth_user.last_name,db.auth_user.email,Link.id,CentroC.nome
,left=[Link.on(Link.userid == db.auth_user.id), CentroC.on(CentroC.id == 
Link.centroid) ])
  
  code = response.session_id
  message = response.status
 
  #retorno de variaveis grid   
  return dict(code=code,message=message,data=data) 
 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to