Code Monkey home page Code Monkey logo

Comments (5)

JISSJOHNSON avatar JISSJOHNSON commented on September 4, 2024 1

fixed the issue

cropperHandler(cropper) {
  var imgdat = cropper.getCroppedCanvas().toDataURL(this.cropperOutputMime);
  var file = this.dataURLtoFile(imgdat, "test.png");
  let formData = new FormData();
  formData.append("photo", file);
  axios({
    method: "POST",
    url: "/product/testupload/",
    headers: {
      "Content-Type": "multipart/form-data",
      to: "token"
    },
    data: formData
  });
},

dataURLtoFile(dataurl, filename) {
  var arr = dataurl.split(","),
    mime = arr[0].match(/:(.*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n);

  while (n--) {
    u8arr[n] = bstr.charCodeAt(n);
  }

  return new File([u8arr], filename, { type: mime });
},

thanks to the thread [https://stackoverflow.com/questions/35940290/how-to-convert-base64-string-to-javascript-file-object-like-as-from-file-input-f/38935990#38935990]

from vue-avatar-cropper.

waLplanet avatar waLplanet commented on September 4, 2024 1

how can i get the original file name via above mentioned instance?

to do so you should listen to changes in the comp:
<avatar-cropper @changed="cropperAvatarChanged" />

and in the method you receive the file, so you can display the filename:

cropperAvatarChanged(file, reader) {
console.log(file.name);
}

from vue-avatar-cropper.

JISSJOHNSON avatar JISSJOHNSON commented on September 4, 2024

how can i get the original file name via above mentioned instance?

from vue-avatar-cropper.

JISSJOHNSON avatar JISSJOHNSON commented on September 4, 2024

Thanks

from vue-avatar-cropper.

waLplanet avatar waLplanet commented on September 4, 2024

Thanks

ok, now you can close the issue

from vue-avatar-cropper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.