我试图使用material UI upload按钮,允许我的用户上传个人资料图像,所以看起来像这样:
<label htmlFor='icon-button-file'>
<Input accept='image/*' id='icon-button-file' type='file' onChange={handleCaptureChange('profileImg')} />
<IconButton
color='secondary'
aria-label='upload picture'
component='span'
>
<StyledUploadButton />
</IconButton>
</label>
这是:
const handleCaptureChange = (prop: keyof State) => (event: React.ChangeEvent<HTMLInputElement>) => {
setValues({
...values,
[prop]: event.target.value
})
}
每当我尝试并选择图像时,我收到的URL如下:
C:\fakepath\b062f046-fcb5-4c99-bd19-1FF9C11EFED。jpg
这张图片在我的桌面上,这很奇怪,我应该如何找到图片的正确位置?