jquery - Image Upload And Crop -


i using js cropper crop image. before using functions upload image when click on brows. in file element. fresher don't know it. when uploading image first time works fine after going wrong. not able understad.

    function checkfunction()     {          $("#upload").change(function() {        var file = this.files[0];       var imagefile = file.type;       var match= ["image/jpeg","image/png","image/jpg"];         if(!((imagefile==match[0]) || (imagefile==match[1]) || (imagefile==match[2])))       {        return false;       }       else       {          var form_data = new formdata();          form_data.append("file", file)                   $.ajax({                      type: 'post',                       url: 'upload.php',                       datatype: 'script',                       cache: false,                       contenttype: false,                       processdata: false,                       data:form_data,                       success: function(data)                         {                            if(data != '')                           {                             $("#preview" ).append(data);                           }                         }                     });       }          });     return true; }        function startcrop(uploaddata)       {         alert(uploaddata);           $(function () {            var $image = $('#image');            var $button = $('#button');            var croppable = false;             $image.cropper({              aspectratio: 16 / 4,             viewmode: 3,              dragmode: 'move',              autocroparea: 1,              restore: false,              guides: false,              highlight: false,              cropboxmovable: true,              cropboxresizable: true,              ready: function () {                croppable = true;              }            });             $button.on('click', function () {              var croppedcanvas;               if (!croppable) {                return;              }               croppedcanvas = $image.cropper('getcroppedcanvas');              var croppng = croppedcanvas.todataurl("image/png");               var random=math.floor(math.random() * 999999) + 0;                $.ajax({                      type: 'post',                       url: 'upload.php',                       data:                        {                         pngimagedata: croppng,                         filename: 'images/'+random+'.png',                         returndata: random+'.png',                         last:uploaddata                        },                       success: function(data)                         {                             console.log("cropped");                              //$("#preview").find('img:first').remove();                             $('#modal').modal('hide');                             $image.cropper('destroy');                          }                     });          })                }); return true; } 

here code. please help.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -