advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
977 stars 132 forks source link

Cannot read property 'toDataURL' on canvas=false #143

Closed alejandri closed 3 years ago

alejandri commented 3 years ago

Hi, on this great package. I have a problem with Cors t show image from server, then I set attr canvas="false". With this solve image display. But I want save img, All examples are based on canvas object. How I can save cropped img?

  <cropper
        ref="cropper"
        class="cropper"
        :src="avatar"
        :canvas="false"
        :transitions="true"
        default-boundaries="fill"
        image-restriction="fit-area"
        @change="change"
      /> 
      <v-btn text @click="download"> aplicar </v-btn>
    download({ coordinates }) {
      const { canvas } = this.$refs.cropper.getResult();
      const newTab = window.open();
      newTab.document.body.innerHTML = `<img src="${canvas.toDataURL()}"></img>`;
    }

Laravel 8, Vue Js 2

Norserium commented 3 years ago

@alejandri, no, you can't. If the response doesn't have appropriate Access-Control-Allow-Origin header, you can't retrieve the image content in the browser by security reasons.

There is the CORS guide in the documentation. I hope it will be helpful for you.

Norserium commented 3 years ago

@alejandri, I close the issue due inactivity. Feel free to reopen.