53 lines
1.4 KiB
Cheetah
53 lines
1.4 KiB
Cheetah
<form method="post" action="" enctype="multipart/form-data" id="myform">
|
|
<button type="submit" class="btn btn-success">Valider</button>
|
|
<button onClick="parent.$('#mymodallarge').modal('hide')" class="btn btn-secondary">Annuler</button>
|
|
</form>
|
|
|
|
<center class="mb-3">
|
|
<div class="preview" style="overflow:hidden; height:90px;"></div>
|
|
</center>
|
|
|
|
<div>
|
|
<img id="image" src="{{.pathfile}}" style="width:100%">
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
|
image = document.getElementById('image');
|
|
const cropper = new Cropper(image, {
|
|
aspectRatio: 1 / 1,
|
|
preview: '.preview',
|
|
});
|
|
|
|
$("#myform").submit(function (e) {
|
|
e.preventDefault();
|
|
|
|
var formdata = new FormData(document.querySelector('form'));
|
|
|
|
result=cropper.getCroppedCanvas({ maxWidth: 4096, maxHeight: 4096 });
|
|
result.toBlob(function (blob) {
|
|
file = new File([blob], 'crooped.jpg');
|
|
formdata.append("file", blob, 'thumb_{{.filename}}');
|
|
|
|
$.ajax({
|
|
url: "{{.submitroute}}",
|
|
data: formdata,
|
|
type: "POST",
|
|
processData: false,
|
|
contentType: false,
|
|
success: function( response) {
|
|
{{ if .iscallback }}
|
|
parent.CallbackUpload("{{.id}}","{{.path}}",response.file);
|
|
{{ else }}
|
|
document.location.href="{{.redirect}}";
|
|
{{ end }}
|
|
}
|
|
});
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
</script>
|