GithubHelp home page GithubHelp logo

Comments (5)

Crael94 avatar Crael94 commented on September 26, 2024 45

Hello @einazare,

Thank you for this answer, I found a solution, here is my code:

imageUpload.jsx

handleImageChange(e) {
    e.preventDefault();
    let file = e.target.files[0];
    let reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onloadend = () => {
      this.setState({
        file: file,
        base64: reader.result
      });
      this.handleSubmit()
    };
  }

In this function the issue was reader.readAsDataURL(file) (line 33). It has to be before the onloadend. Then the reader.result is the a base64 string of the file.

I hope I can help someone !

from ct-material-kit-pro-react.

einazare avatar einazare commented on September 26, 2024

Hello there, @Crael94 ,

Thank you for your interest in working with our products.
Sorry for this late response, since I am a Christian I've had some free days for the Easter Holiday:

At the moment we haven't worked with back-end logic, and we do not really know how you would submit something to your back-end. This being said, without knowing I believe that the handleSubmit should be called inside the reader.onloadend function. Also, you should change the code inside the handleSubmit function - it is a blank function, it doesn't do anything. And, since this is React that we are talking about, most definitely this function should have an Ajax call to a REST API. But once again, we are just front-end developers. There may be more to this.

Hope this will help.

All the best,
Manu

from ct-material-kit-pro-react.

einazare avatar einazare commented on September 26, 2024

Hello again, @Crael94 ,

I will leave this issue open. As you've said it, maybe it will help someone.

All the best,
Manu

from ct-material-kit-pro-react.

alcalcides avatar alcalcides commented on September 26, 2024

Thank you so much for your help

from ct-material-kit-pro-react.

piedrucci avatar piedrucci commented on September 26, 2024

@Crael94 this is great!, it works for me. very helpful.. thanks so much

from ct-material-kit-pro-react.

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.