当前位置:首页 » 文件管理 » 上传绑定事件

上传绑定事件

发布时间: 2025-01-21 21:21:03

‘壹’ easyui 1.4 控件filebox 怎么在点击上传时触发一个事件

绑定onChange事件就行了,filebox继承自textbox,textbox的事件都可以作用于filebox

<input class="easyui-filebox" name="file1" data-options="onChange:function(){alert('change file')},prompt:'Choose a file...'" style="width:100%">

‘贰’ vue移动端文件上传调用手机文件

创建文件选择按钮。
1、在Vue组件中创建一个用于选择文件的按钮。
2、使用Vue的事件绑定,监听文件选择按钮的change事件。
3、利用Vue的HTTP库(如axios)或其他文件上传插件,将选择的文件上传至服务器。

‘叁’ 使用jquery.form.js实现文件上传及进度条前端代码

ajax的表单提交只能提交data数据到后台,没法实现file文件的上传还有展示进度功能,这里用到form.js的插件来实现,搭配css样式简单易上手,而且高大上,推荐使用。

需要解释下我的结构, #upload-input-file 的input标签是真实的文件上传按钮,包裹form标签后可以实现上传功能, #upload-input-btn 的button标签是展示给用户的按钮,因为需要样式的美化。上传完成生成的文件名将会显示在 .upload-file-result 里面, .progress 是进度条的位置,先让他隐藏加上 hidden 的class, .progress-bar 是进度条的主体, .progress-bar-status 是进度条的文本提醒。

去掉hidden的class,看到的效果是这样的
[图片上传失败...(image-2c700a-1548557865446)]

将上传事件绑定在file的input里面,绑定方式就随意了。
var progress = $(".progress-bar"), status = $(".progress-bar-status"), percentVal = '0%'; //上传步骤 $("#myupload").ajaxSubmit({ url: uploadUrl, type: "POST", dataType: 'json', beforeSend: function () { $(".progress").removeClass("hidden"); progress.width(percentVal); status.html(percentVal); }, uploadProgress: function (event, position, total, percentComplete) { percentVal = percentComplete + '%'; progress.width(percentVal); status.html(percentVal); console.log(percentVal, position, total); }, success: function (result) { percentVal = '100%'; progress.width(percentVal); status.html(percentVal); //获取上传文件信息 uploadFileResult.push(result); // console.log(uploadFileResult); $(".upload-file-result").html(result.name); $("#upload-input-file").val(''); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(errorThrown); $(".upload-file-result").empty(); } });

[图片上传失败...(image-3d6ae0-1548557865446)]

[图片上传失败...(image-9f0adf-1548557865446)]

更多用法可以 参考官网

热点内容
战争年代密码叫什么 发布:2025-07-14 22:25:29 浏览:709
安卓手机没信号了代表什么 发布:2025-07-14 22:21:48 浏览:352
玩客云文件夹共享服务器 发布:2025-07-14 22:11:35 浏览:716
如何将摩斯密码变成输入法 发布:2025-07-14 22:07:07 浏览:933
煤矿需配置哪些保安电源 发布:2025-07-14 22:07:02 浏览:631
脚本漏洞类型网络型 发布:2025-07-14 21:58:49 浏览:392
安卓视频文件删除后怎么恢复 发布:2025-07-14 21:56:32 浏览:944
无敌脚本盒子 发布:2025-07-14 21:50:37 浏览:955
dbscan聚类python 发布:2025-07-14 21:36:09 浏览:31
海岛图怎么配置枪 发布:2025-07-14 21:35:07 浏览:324