Comments (9)
@michaelpoltorak you can pass that through uploadProps on the component, ex uploadProps={{onClick: () => blah}}
👍
from cj-upload.
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.
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.
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.
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.
@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.
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.
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.
@zackify: Perfect. And thanks.
from cj-upload.
Related Issues (20)
- Is there a function that gets called when the user hits cancel? HOT 5
- Progress value from 0 to 1? Or from 0 to 100? HOT 1
- how to clear the selected files? HOT 1
- Styling input[type=file] HOT 5
- Reset uploader state HOT 15
- TypeError: instance is not a function HOT 3
- UploadRequest resolves with error for 2xx status codes other then 200 and 201 HOT 2
- React 16 Upgrade HOT 1
- How to limit the size of uploaded files? HOT 1
- Access the input ref HOT 2
- Unable to catch error response details HOT 2
- Support multiple files and returning a list of states
- fileName will never be null
- Reset the files array and progress if upload fails
- How to get files before upload? HOT 4
- Unable to get header values while using UploadRequest to upload file. HOT 1
- Support multiple files at once HOT 3
- Return failed if response code is 500, not complete HOT 1
- onFiles never called. HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cj-upload.