> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/keyboard/file-upload.md).

# 文件上传

文件上传是指命令浏览器自动将一个或多个文件（图片、视频、Excel文档、txt等）从您的计算机上传到目标网站的服务器。

#### 配置参数：

* XPath：指向网站文件上传框的标识符路径（XPath）。

  > ⚠️ 重要提示：在通过代码进行自动化时，请不要直接点击带有“选择图片”或“上传图片”字样的按钮（因为这会打开Windows/macOS的文件选择窗口，导致脚本卡住）。相反，您必须找到正确的隐藏标签，其结构为：`//input[@type='file']`，并将XPath填入此框中。
* 文件路径：指向您计算机上正在保存的文件的绝对路径（例如：`C:\Users\Admin\Desktop\avatar.png`）。您可以在此处传递包含动态路径的变量（例如：`$filePath`）。

#### 实际示例：将产品图片上传到系统

当您编写自动发布销售商品（产品列表）脚本到电子商务平台或社交网络时，标准处理流程如下：

* 配置方式：
  * 元素XPath：`//input[@type='file' and @name='product_image']`（扫描网页源代码以查找此隐藏input标签）。
  * 文件路径：`D:\DataPOD\Design01.png`
* 操作逻辑：GPM Automate将直接将文件路径`D:\DataPOD\Design01.png`传递到网页的`input`元素中。网站系统将立即识别并开始顺利上传图片，而不会弹出操作系统的打开文件对话框。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/keyboard/file-upload.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
