0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

svgタグの画像でinput type="file"の「選択されていません」を置き換える

Last updated at Posted at 2020-04-25
const FileUpload:React.FC = () => {
    const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
        // これで取り出す
        const file: File | undefined = e.target.files?.[0]
    }

    return <>
        <input id={"uploadEventAttachment"} type={"file"} value={''}
               onChange={onChange}
               style={{display: "none"}}/>
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
             onClick={() => (document.querySelector("#uploadEventAttachment") as HTMLInputElement).click()}>
            <path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"/>
        </svg>
    </>
}

mouseOver時の変化がほしいところ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?