Coder Social home page Coder Social logo

Comments (9)

zackify avatar zackify commented on August 13, 2024 1

@michaelpoltorak you can pass that through uploadProps on the component, ex uploadProps={{onClick: () => blah}} 👍

from cj-upload.

zackify avatar zackify commented on August 13, 2024

Every time a change occurs the onChange is triggered, if the file isn't changed, it's not going to happen. Why would you want to upload the same file twice? This seems out of the scope of the component, all it does is wrap an input and onChange, nothing special.

from cj-upload.

bionicvapourboy avatar bionicvapourboy commented on August 13, 2024

My fault, I was trying to upload 2 file with the same name and content generated automatically in the same moment. When content or date changes upload triggers correctly.

from cj-upload.

michaelpoltorak avatar michaelpoltorak commented on August 13, 2024

In my code I intercept the upload process to display a UI component before doing the upload request. Hence, the user may end up in a situation where it actually makes sense to upload the same file twice.

Is it possible you could make re-uploading an option?

from cj-upload.

zackify avatar zackify commented on August 13, 2024

I'm not doing anything special, as you can see here. https://github.com/navjobs/upload/blob/master/src/upload-field.js#L25

It simply calls onChange when something changes.

What your asking is the same as "I have an input field, I want onChange called again, even when nothing changes"

A solution for you would be to store the files object, ex onFiles={files => this.setState({files})}

Now, when your ui component says there was a problem uploading, you can grab the files again from this.state.files and reupload them :)

Hope that helps! @michaelpoltorak

from cj-upload.

michaelpoltorak avatar michaelpoltorak commented on August 13, 2024

@zackify I'm not sure I made my self entirely clear - my bad.

What I need is that the value on the input be reset after an upload. It can be done by simply adding a handler that resets the value on click like this:

<input type='file' onClick={(e) => { e.target.value = ''; } onChange={(e) => ...} />

How does that sound to you?

from cj-upload.

zackify avatar zackify commented on August 13, 2024

I see, how about this: https://github.com/navjobs/upload/releases/tag/3.1.3 Now you can add the onChange handler yourself! @ michaelpoltorak

from cj-upload.

michaelpoltorak avatar michaelpoltorak commented on August 13, 2024

Brilliant.
I still need to be able to reset the input value on click, so if you could add a custom onClick handler too, I'd be very happy :-) Thanks for the quick responses.

from cj-upload.

michaelpoltorak avatar michaelpoltorak commented on August 13, 2024

@zackify: Perfect. And thanks.

from cj-upload.

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.