Advertisement
renatoSouza

Untitled

Sep 20th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.54 KB | None | 0 0
  1. var form;
  2. $('#file').change(function (event) {
  3.   form = new FormData();
  4.   form.append('file', event.target.files[0]); // para apenas 1 arquivo  
  5. });
  6.  
  7. $(".btnCNHSuporte").click(function(e){
  8.   e.preventDefault();
  9.  
  10.     $.ajax({
  11.       "async": true,
  12.       "crossDomain": true,
  13.       "url": linkAPI + "/api/motoristas/" + localStorage.getItem('id') + "/doc-pessoal",
  14.       "method": "POST",
  15.       "headers": {
  16.         "authorization": "Basic dmFwdFViZXI6QFExQ3ViMA==",
  17.         "cache-control": "no-cache",
  18.         "postman-token": "e3e2fec2-3439-2eb5-6202-47dc64129d3c"
  19.       },
  20.       "processData": false,          
  21.       "contentType": false,
  22.       "mimeType": "multipart/form-data",
  23.       "data": form,
  24.       success: function(retorno){
  25.         Materialize.toast('Imagem enviada com sucesso!', 5000, 'orange rounded')
  26.         setTimeout(function(){
  27.         var sendOKCNH = 1;
  28.         localStorage.setItem('sendOKCNH', sendOKCNH);
  29.         $(".uploadMotociclista").load(dominio + '/cadastro/motociclista/upload_motociclista.php');    
  30.  
  31.       }, 1000);      
  32.  
  33.       }, error:        
  34.       function (xhr, textStatus, errorThrown) {
  35.         Materialize.toast('Falha no envio, por favor, verifique o tamanho da imagem e formato correto (JPG e/ou PNG).', 5000, 'orange rounded');
  36.  
  37.        setTimeout(function(){
  38.         var sendOKCNH = 0;
  39.         localStorage.setItem('sendOKCNH', sendOKCNH);
  40.         $(".uploadMotociclista").load(dominio + '/cadastro/motociclista/upload_motociclista.php');    
  41.       },2000);      
  42.       }
  43.  
  44.     });  
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement