App.jsx
import React from 'react';
import Upload from './Upload';
const App = () => {
return (
<React.Fragment>
<Upload />
</React.Fragment>
);
}
export default App;
Upload.jsx
import React from 'react';
const Upload = () => {
const handleInputChange = (event) => {
const file = event.target.files[0];
console.log('fileName:', file.name);
}
return (
<React.Fragment>
<input type='file' onChange={handleInputChange} />
</React.Fragment>
);
}
export default Upload;