Git Product home page Git Product logo

Comments (5)

GrzegorzWalewski avatar GrzegorzWalewski commented on May 24, 2024 1

Thanks, it works 😄

from file-upload-with-preview.

deniseileen avatar deniseileen commented on May 24, 2024

Because of some recent changes that we’re working through, you’re going to want to make sure you’re including the library at a certain version. To anyone coming to this issue with a new TypeError: FileUploadWithPreview is not a constructor error, you should update your javascript library script import to <script src="https://unpkg.com/[email protected]/dist/file-upload-with-preview.min.js"></script>. See below for another way to fix the issue, but may leave you with an error in the future. It’s pretty universally recommended to specify versions in dependencies for safety reasons.

Initial answer:

Hey, sorry about that - we made some changes today that affect the usage. You can either update your code to use .default on the initialization: var upload = new FileUploadWithPreview.default('myUniqueUploadId'), or you can specify an older version - changing to 3.1.3 should solve the issue for you.

from file-upload-with-preview.

johndatserakis avatar johndatserakis commented on May 24, 2024

Hey Grzegorz - we just pushed a fix to the default issue. If you have not hardcoded the version number in you importing of this library, then you may run into an issue with this latest push.

If you do run into an issue now, please use the following import code to lock in your version:

<script src="https://unpkg.com/[email protected]/dist/file-upload-with-preview.min.js"></script>

Also, you can remove the default from your initialization. So it should look like this:

var upload = new FileUploadWithPreview('myUniqueUploadId')

Sorry for the trouble and for you having to update your code. Please let us know if we can assist further. Thank you.

from file-upload-with-preview.

rogerarruda avatar rogerarruda commented on May 24, 2024

Hello, I'm having the same problem importing from NPM into a JS file.

File plugins.js using webpack:

window.FileUploadWithPreview = require('file-upload-with-preview');

When I see in the browser, the error appears:

Uncaught TypeError: FileUploadWithPreview is not a constructor

My script into HTML

<script type="application/javascript">
        const upload = new FileUploadWithPreview('uploadImage', { text: {chooseFile: 'Selecione um arquivo', browse: 'Selecionar'} });
</script>

from file-upload-with-preview.

wikichua avatar wikichua commented on May 24, 2024

on app.js
const FileUploadWithPreview = window.FileUploadWithPreview = require('file-upload-with-preview/src/file-upload-with-preview').default;

from file-upload-with-preview.

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.