File Upload (5 Entry Points) new 文件上传(5 种入口) web

01/05
01 Local file
PDF, JPG, PNG or DOCX, up to 10MB each
    Drag files here or

      What is wrong in this screenshot?

      Take a screenshot, click the box, press ⌘V / Ctrl+V

        Files stay in this page for preview; nothing is uploaded.

        标本可交互,可以直接操作。

        Anatomy — every part, named解剖 —— 每个部件的名字

        1. 1 Local file picker本地文件选择 <input type="file">

          A Choose file button with formats and size limit stated, plus a removable file list.

          「选择文件」按钮,写清格式和大小上限,文件列表可移除。

          Prompt fragmentPrompt 片段

          the local picker: a Choose file button with allowed formats and size limit underneath

          本地选择:「选择文件」按钮,下方写支持的格式和大小上限

        2. 2 Dropzone拖放区 drop event

          A target that clearly reacts while a file is dragged over it, and still offers a browse link.

          文件拖到上方时有明确反馈,同时保留点击选择的入口。

          Prompt fragmentPrompt 片段

          the dropzone: dashed by default, solid and tinted while a file is over it, with a browse link

          拖放区:默认虚线,文件拖到上方时变实线加底色,保留「点击选择」

        3. 3 Paste target粘贴目标 paste event

          A composer that turns pasted screenshots into removable thumbnails while text continues.

          输入框把粘贴的截图变成可移除的缩略图,文字可以继续写。

          Prompt fragmentPrompt 片段

          the paste target: pasted images appear as removable thumbnails above the message text

          粘贴目标:粘贴的图片以可移除缩略图出现在文字上方

        4. 4 Camera capture拍照采集 capture attribute

          Take a photo, preview it, retake or confirm, with a library option nearby.

          拍照、预览、重拍或确认,旁边保留相册入口。

          Prompt fragmentPrompt 片段

          the camera capture: shutter, preview with Retake and Use photo, and a choose-from-library link

          拍照:快门、带「重拍」「使用照片」的预览,以及「从相册选择」

        5. 5 Link import链接导入 fetch

          Import from an address; loading, success and a specific failure reason are all shown.

          从地址导入;加载、成功和具体的失败原因都要显示。

          Prompt fragmentPrompt 片段

          the link import: URL field, Import button, loading state and a specific error message

          链接导入:网址输入框、导入按钮、加载状态和具体的错误提示

        6. 6 File list文件列表 URL.createObjectURL

          Each added file shows a thumbnail, name, size or progress, and a remove button.

          每个文件显示缩略图、名称、大小或进度,以及移除按钮。

          Prompt fragmentPrompt 片段

          the file list: thumbnail, name, size or progress bar, and a remove button for each file

          文件列表:每项有缩略图、名称、大小或进度条和移除按钮

        Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

        Build a file upload area that offers five entry points and lets people combine them: 1 Local file: a Choose file button over <input type="file"> with the allowed formats and size limit written underneath, a file list with remove buttons so people can re-pick. 2 Drag and drop: a dashed dropzone that turns solid and tinted while a file is over it, shows per-file progress after the drop, and keeps a 'browse' link. 3 Paste: in the message composer, read images from the clipboard on paste, show a removable thumbnail above the text and keep the caret so people can keep typing. 4 Camera: on mobile use accept="image/*" capture to take a photo, then show a preview with Retake and Use photo, and keep a 'choose from library' option. 5 From link: a URL field with an Import button; validate the address, show a loading state, and on failure explain why (broken link, not an image, or login required). Preview files locally with object URLs before uploading.

        做一个提供五种入口、也能组合使用的文件上传区:1 本地文件:「选择文件」按钮包住 <input type="file">,下方写清支持的格式和大小上限,文件列表每项都能移除后重选。2 拖拽上传:虚线拖放区,文件拖到上方时变成实线并加底色,放下后显示每个文件的进度,同时保留「点击选择」入口。3 粘贴上传:在消息输入框里监听粘贴,读取剪贴板图片,在文字上方显示可移除的缩略图,光标保留以便继续输入。4 拍照上传:手机上用 accept="image/*" capture 拍照,之后显示预览和「重拍」「使用照片」,并保留「从相册选择」。5 链接导入:网址输入框加「导入」按钮;校验地址,显示加载状态,失败时说明原因(链接打不开、不是图片或需要登录)。上传前先用本地地址预览文件。

        Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

        Debug my file upload. Check that accept and the size limit are enforced in code, not only stated; the dropzone calls preventDefault on dragover so drop fires, and leaves the over state on dragleave and drop; paste reads clipboardData.items of type image/* and ignores plain text; camera capture falls back to the normal picker on desktop; link import validates the URL and reports a specific reason when the fetch fails or is blocked by CORS or auth; every file can be removed and re-picked; object URLs are revoked; and all entry points are reachable by keyboard. The symptom:

        调试我的文件上传。检查:格式和大小限制是否在代码里真正校验,而不只是写在说明里;拖放区是否在 dragover 里调用 preventDefault,所以 drop 能触发,dragleave 和 drop 后是否退出高亮;粘贴是否只读取 image/* 类型的剪贴板项、忽略纯文本;电脑上拍照入口是否退回普通文件选择;链接导入是否校验地址,取不到或被跨域、登录拦住时是否给出具体原因;每个文件能否移除后重选;本地预览地址是否及时释放;以及所有入口能否用键盘操作。症状是:

        In code代码里叫什么

        Framework框架Symbol符号Note说明
        HTML <input type="file" accept multiple> the native file picker; accept limits types, multiple allows several files原生文件选择器;accept 限制类型,multiple 允许多选
        Web dragover / drop + DataTransfer.files drag and drop from the desktop; call preventDefault on dragover从桌面拖文件进来;dragover 里要调用 preventDefault
        Web paste event + ClipboardEvent.clipboardData read pasted images as files without saving them first不用先保存,直接读取粘贴的图片
        HTML <input type="file" accept="image/*" capture> opens the camera on phones; getUserMedia for an in-page viewfinder手机上直接打开相机;页面内取景用 getUserMedia
        Web fetch(url) → Blob (server-side for other origins) import from a link; cross-origin files usually need your server to fetch them从链接导入;跨域文件通常要由自己的服务器去取
        Web URL.createObjectURL local thumbnail previews before anything is uploaded上传前先用本地地址显示缩略图

        See also相关词条

        我的参考集

        组合知名网站、UI 元素、视觉风格和平面设计案例,导出给 AI。

        你的下一份设计,从这里开始。

        在任意案例旁点击「加入参考」,就能把品牌、组件、风格和平面设计案例组合成一份 AI 设计说明。

        搜索参考库Search the library

        输入关键词,搜索所有参考。