Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong react file upload code #375

Open
joubeh opened this issue Dec 24, 2024 · 2 comments
Open

Wrong react file upload code #375

joubeh opened this issue Dec 24, 2024 · 2 comments

Comments

@joubeh
Copy link

joubeh commented Dec 24, 2024

The react code in page "https://inertiajs.com/file-uploads" for uploading files using useForm hook has error.
<input type="file" value={data.avatar} onChange={e => setData('avatar', e.target.files[0])} />
The code value={data.avatar} should be removed. it gets error because: InvalidStateError: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.

@Jussi-Mannisto
Copy link

The attribute value={data.avatar} causes the issue, and removing it resolves it. The value attribute of a file input cannot be programmatically modified, except by setting it to an empty string.

@JsExpertCoder
Copy link

yes @joubeh, and you are right @Jussi-Mannisto , I also notice that, and I submitted a PR: #396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants