Foliotek / Croppie

A Javascript Image Cropper
http://foliotek.github.io/Croppie
MIT License
2.56k stars 884 forks source link

Can this be done without AJAX #680

Closed cyjobes closed 5 years ago

cyjobes commented 5 years ago

Everything I see has AJAX in it. Please show how to use this with a normal form, if possible.

thedustinsmith commented 5 years ago

There's several different ways to do it, the least amount of code would be using the base64 string and placing it in a hidden input and submitting that form via js.

I haven't actually tested the code below, but it should get you started.

<form method="POST" action="your url">
<input type="hidden" id="base64Image" name="base64Image" />
</form>

<script>
var croppie = new Croppie(); // insert your options here.
croppie.result('base64').then(function(b64String) {
    document.querySelector('#base64Image').value = b64String;
    document.querySelector('form').submit();
});
</script>
cyjobes commented 5 years ago

Have no idea how you are using this.

cyjobes commented 5 years ago

Sorry, meant to say thank you. Was just frustrated to not being able to find answers on how to use this. It was obviously for your needs.

thedustinsmith commented 5 years ago

Thanks for the back-handed complement.

I'm sorry that the documentation isn't up to your satisfaction. I don't get paid to maintain this library, we open-sourced it to give back to the OS community. If you want to write up some documentation that you think would be better for the community, I'd love to consider implementing it. Maybe the time/effort you put into writing documentation would help you understand the library a little better.

As it is, this issue isn't helpful to the community. You got your point across, I suck at writing documentation. Thanks!