question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upload example not doing anything

See original GitHub issue

I have tried for the last 2 hours messing with different file upload combinations and have even extrapolated the code from the demo website and am currently using that. When I click “Upload,” I get the dialog and can choose any kind of file (jpg, png, gif), and click “Open,” and nothing changes. I don’t even get an error. At one point, I was using some other code and I would get an error in the console regarding “substring of undefined” on line 134, but I no longer get that error using the code from the Croppie demo website. Here is what I am currently using:

HTML

<div class="row">
  <div class="large-6 columns">
    Profile picture upload
    <br>
    <a class="button">
      <span>Upload</span>
      <input type="file" id="profile-picture-upload" accept="image/*" required/>
    </a>
    <small class="error">Please choose or upload your profile picture</small>
  </div>
  <div class="large-6 columns">
    <h6 class="text-center">Profile Picture Preview</h6>

    <div class="text-center">
      <img id="profile-pic-preview" src="http://placehold.it/300.jpg?text=choose+or+upload+a+profile+picture">
    </div>
  </div>
</div>

JS

var $profilePicPreview = $('#profile-pic-preview').croppie({
    viewport: {
      width: 200,
      height: 200,
      type: 'circle'
    },
    boundary: {
      width: 300,
      height: 300
    },
    enableExif: true
  });

function readFile(input) {
  if (input.files && input.files[0]) {
    var reader = new FileReader();

    reader.onload = function (event) {
      $profilePicPreview.croppie('bind', {
        url: event.target.result
      });
    };

    reader.readAsDataURL(input.files[0]);
  } else {
    alert('Sorry - you\'re browser doesn\'t support the FileReader API');
  }
}

$('#profile-picture-upload').on('change', function() { readFile(this); });

This should be exactly what is on the demo page but it isn’t doing anything. Can anyone tell me where I’m making a mistake or what might be interfering with the functionality of this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rubyshine72commented, Jun 13, 2017

$uploadCrop = $(‘#avatar_img’).croppie({ enableExif: true, viewport: { width: 200, height: 200, type: ‘square’ }, boundary: { width: 300, height: 300 } });

var reader = new FileReader(); reader.onload = function (e) { $uploadCrop.croppie(‘bind’, { url: e.target.result }).then(function(){ //console.log(‘jQuery bind complete’); }); } reader.readAsDataURL(this.files[0]);

$uploadCrop.croppie(‘result’, { type: ‘canvas’, size: ‘viewport’ }).then(function (resp) { });

0reactions
rubyshine72commented, Jun 13, 2017

Especially the small image is no problem, but the large image larger than viewport size is problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

forms - File upload not working | Php - Stack Overflow
As soon as I use enctype="multipart/form-data", nothing works at all the page simply refreshes. But, when I'm not using enctype="multipart/form ...
Read more >
Common uploading errors - YouTube Help - Google Support
If you're having problems uploading your video, select the error message you're seeing and follow the troubleshooting steps to solve your issue.
Read more >
is the "upload form" option not working - Xero Central
I am trying to upload my form for my bank feeds application and I click the upload form button but it goes literally...
Read more >
FIXED Contact Form 7 File Upload Not Working ... - YouTube
FIXED Contact Form 7 File Upload Not Working [Still works in 2023!]
Read more >
Upload files and folders to a library - Microsoft Support
Notes: To create and upload files and folders in a library, you must have contributor permissions to the library. If you're not sure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found