Answer the question
In order to leave comments, you need to log in
How to pass cropper result (cropped image) to controller?
There is a cropper:
var image = document.getElementById('cropImage');
if (cropper) { cropper.destroy(); }
cropper = new Cropper(image, {
aspectRatio: 268 / 249,
dragMode: 'none',
autoCropArea: 1,
movable: false,
rotatable: false,
scalable: false,
zoomable: false,
background: false,
viewMode: 3
})
var cropData = cropper.getData(true);
var formData = new FormData();
formData.append("image", files[0]);
formData.append("image", cropData);
var MyAppUrlSettings = {
MyUsefulUrl: '@Url.Action("ImageCreate", "Home")'
}
var request = new XMLHttpRequest();
request.open('POST', MyAppUrlSettings.MyUsefulUrl);
request.onload = function(e) {
if (requestreadyState === 4) {
if (request.status === 200) {
// тут установить src для картинки
} else {
console.error(request.statusText);
}
}
};
request.send(formData);
ActionResult ImageCreate(HttpPostedFileBase image, HttpPostedFileBase crop)
{
...................................................
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question