0

I have code that crops a image when a user clicks on a button:

$('#crop').click(function () {
    var imageDataBase64 = $('#image-cropper').cropit('export');
    var image = new Image();

    image.src = imageDataBase64;
    console.log(image);
});

The picture should be uploaded as a coverpicture for the user.

How should I save this picture? Should I store the base64-code in the database? Or Is there any way to transform the base64 to an image and then store It on disk and then store only the reference to the image in the database?

EDIT:

I found the following solution: C# Base64 String to JPEG Image

Community
  • 1
  • 1
Bryan
  • 3,421
  • 8
  • 37
  • 77
  • What you should store in DB is completely up to you. For the second part there are hundreds of "convert data image to file" questions... You may want to research existing solutions first... – Alexei Levenkov May 16 '16 at 03:47
  • _"Or Is there any way to transform the base64 to an image"_ What is `imageDataBase64` ? The `base64` string could be `data URI` representation of image file – guest271314 May 16 '16 at 03:47
  • @AlexeiLevenkov: But what Is a good solution for this? I have done some researched, and I can't really find anything that says that I can transform a base64-string to a jpeg-file and then store It on disk programmatically. Any ideas? – Bryan May 16 '16 at 03:50
  • guest271314: What? ImageDataBase64 Is the base64 string. – Bryan May 16 '16 at 03:51
  • Never mind. I found a solution. – Bryan May 16 '16 at 03:52
  • I have no idea what/where are you searching - https://www.bing.com/search?q=c%23+save+data+image+base64+file gives http://stackoverflow.com/questions/5400173/converting-a-base-64-string-to-an-image-and-saving-it – Alexei Levenkov May 16 '16 at 03:53
  • Please do not edit answers into questions. Looks like flagging as duplicate or deleting is right solution (if your solution is more than link to existing SO question posting self-answer would be appropriate) – Alexei Levenkov May 16 '16 at 03:55

0 Answers0