easyui上传文件
时间: 2023-11-24 20:06:24 浏览: 97
EasyUI 提供了一个名为 `filebox` 的组件,可以用来实现文件上传功能。使用该组件需要引入 EasyUI 的相关文件和 jQuery 库。
以下是一个简单的示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EasyUI 文件上传示例</title>
<link rel="stylesheet" type="text/css" href="https://cdn.bootcdn.net/ajax/libs/jquery-easyui/1.9.21/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="https://cdn.bootcdn.net/ajax/libs/jquery-easyui/1.9.21/themes/icon.css">
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery-easyui/1.9.21/jquery.easyui.min.js"></script>
</head>
<body>
<form id="uploadForm" method="post" enctype="multipart/form-data">
<input class="easyui-filebox" name="file" data-options="prompt:'选择文件...',buttonText:'浏览',width:200"></input>
<a href="#" class="easyui-linkbutton" onclick="submitForm()">上传</a>
</form>
<script type="text/javascript">
function submitForm() {
$('#uploadForm').form('submit', {
url: 'upload.php',
success: function(data) {
alert(data);
}
});
}
</script>
</body>
</html>
```
其中,`filebox` 组件用于选择文件,`linkbutton` 组件用于触发上传操作。在 `submitForm` 函数中,使用 `form` 方法提交表单,并指定上传文件的 URL 和上传成功后的回调函数。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)