react-images-upload icon indicating copy to clipboard operation
react-images-upload copied to clipboard

can I get image path?

Open divinzer opened this issue 7 years ago • 2 comments

This is so nice uploader and I like it

onChange function didnt return image path but only image name How can I get image path and image name?

Thank you.

divinzer avatar Aug 07 '18 08:08 divinzer

same, I also need the image path

sgentile avatar May 13 '20 16:05 sgentile

Well, I did this in my onDrop function:

const onDrop = (picture) => {    
    // use the FileReader to decode de picture file that comes
    let reader = new FileReader();
    let url = reader.readAsDataURL(picture[0]); // for the first picture in this case

    reader.onloadend = function (e) {
      // the reader.result variable will have your url, in this case I set the pictureUrl state to that
      setPictureUrl(reader.result);
    };
  };

and I can show the image in some preview in the page like this:

<img style={{ height: "50px", width: "50px" }} src={pictureUrl} />

** I have the following hooks, just in case it was not clear:

const [pictureUrl, setPictureUrl] = useState("");

NickNish09 avatar May 23 '20 22:05 NickNish09