• 01-01-2021, 19:44:10
    #1
    http://prntscr.com/we7nyj
    ajax ile fotograf kırpıp sunucuya yuklemek istiyorum nette bir çok örnek var ama formum da başka text input verilerim oldugundan sorun yasadım suanda tüm verileri ajax ile atabiliyorum php dosyama ama resmi tüm haliyle yüklüyordu. şuanda ise http://prntscr.com/we7pjm bu şekilde 0kb olarak yüklüyor.
    js kodlarım bunlar

      
    $image_crop = $('#image_demo').croppie({    
    enableExif: true,    
    viewport: {      width:200,      height:200,      
    type:'square' //circle    },    
    boundary:{      width:300,      height:300    }  });
      
    $('#fotograf').on('change', function(){    
    var reader = new FileReader();    reader.onload = function (event) {      
    $image_crop.croppie('bind', {        
    url: event.target.result      }).then(function(){        
    console.log('jQuery bind complete');      });    }    
    reader.readAsDataURL(this.files[0]);    
    $('#uploadimageModal').modal('show');  });
    
    
    $('.crop_image').on('click', function (event) {  
    $image_crop.croppie('result', {    
    //type: 'base64',    
    format: 'jpeg',    
    type: 'canvas',    
    size: 'viewport'   }).then(function (response) {    
    $('#item-img-output').attr('src', response);    
    $('#uploadimageModal').modal('hide');  });});  
    
    
    $(document).on("submit", "#ogrenci_ekle", function(event2){    
    event.preventDefault();    
    $.ajax({      url: "ajax/ogrenci_ekle.php",              
    type: "POST",      
    data: new FormData(this),      
    contentType: false,      
    cache: false,      
    processData:false,              
    error: function(xhr, status, error) {          
    $("#ogrenci_ekle_no").empty().append(status);          
    $("#ogrenci_ekle_no").append(xhr.responseText);      },      
    success: function(results) {          
    $("#ogrenci_ekle_no").empty();          
    $("#ogrenci_ekle_ok").empty().append(results);      }    });  });
    php dosyamdaki kodlar

    $ogrenci_no = strip_tags($_POST['ogrenci_no']);
    $ogrenci_sifre = strip_tags($_POST['ogrenci_sifre']);
     
     if(isset($_POST['fotograf'])){        
    $data = $_POST['fotograf'];
    list($type, $data) = explode(';', $data);        
    list(, $data)      = explode(',', $data);        
    $data = base64_decode($data);        
    file_put_contents('image64.png', $data);    }
    geçen seneden beri (: (2 hafta kadardır uğraşıyorum) yapamadım yardımcı olabilirseniz çok memnun olurum gerçekten. ilgilenenlere şimdiden çok teşekkür ediyorum
  • 01-01-2021, 22:59:44
    #2
    ücretli destek de alabilirim