Foliotek / Croppie

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

Croppie result to send to web server as a file #728

Open purukc opened 4 years ago

purukc commented 4 years ago

Expected Behavior

We are using croppie.js for image upload on one of our project. I'm able to get my cropped result and send it to my web server as base64 string. But, I need to send the result to server as a file. I am doing this on C#.

So, Is there anyway that Croppie is able to output the result as an actual image file rather than just an encoded base64 version of it. I'm hoping someone might have an easy solution.

Actual Behavior

Steps to Reproduce the Problem

1. 1. 1.

Example Link

Please recreate your issue using JSbin, JSFiddle, or Codepen.

Specifications

bret-miller commented 4 years ago

I don't think you can. I'm using PHP for my conversion from base64, but searching for how to do it in C# yielded this:

string filePath = "MyImage.jpg";
File.WriteAllBytes(filePath, Convert.FromBase64String(base64imageString));

In looking at my own PHP code, it seems there was something prepended to the base64 data, because I have this in my code before converting from base64:

$imageData = substr($imageData,strpos($imageData, ",") + 1);

I'm sure that's not hard to replicate in C# either.

ericgoe commented 4 years ago

This could answer your question. https://stackoverflow.com/a/1588323/7905415