webupload 动态修改url

<div id="uploadOrDownloadBillWin" class="modal fade" tabindex="-1" data-width="500" data-backdrop="static">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
				<h4 class="modal-title">下载模板/导入账单</h4>
			</div>
			<div class="modal-body form">
				<form class="form-horizontal" role="form">
					<div class="form-body">
						<h5 class="block"> 第一步: 请按EXCEL格式填写数据 </h5>
						<a href="javascript:;" target="_bank" download="bill-template.pdf" class="filter-down-excel">
							<i class="fa fa-download"></i> 下载EXCEL模板
						</a>
						
						<h5 class="block"> 第二步: 请上传附件以验证数据格式是否正确 </h5>
						<div id="filter-updown-excel">
							<a class="dt-button btn blue dropdown-toggle upload-excel" title="上传账单模板并验证">
								<i class="fa fa-upload"></i> 上传账单模板并验证
							</a>
						</div>
						
						<h5 class="block">第三步: 确认以上导入账单信息</h5>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" data-dismiss="modal" class="btn btn-outline dark">关闭</button>
			</div>
		</div>

 

/**
 * 初始化上传下载
 */
function initUploadBill() {
	
	$('.filter-down-excel', '#uploadOrDownloadBillWin').unbind('').bind('click', function() {
		// 下载模板
		// window.open(OSS.APISERVER.SHAREBILL + '/rest/bill/model/' + OssUtil.getApiToken() + '/download');
		$(this).attr('href', OSS.APISERVER.SHAREBILL + '/rest/bill/model/' + OssUtil.getApiToken() + '/download');
	});
	
	// 上传
	var templateUploader = WebUploader.create({
		pick: '#filter-updown-excel',
		auto: true,
		swf: '/assets/global/plugins/webuploader-0.1.5/Uploader.swf',
		server: OSS.APISERVER.FILE + '/rest/media/upload/' + OssUtil.getApiToken(),
		method: 'POST',
		fileVal: 'uploadExcel',
		accept: {
			title: 'Excel',
			extensions: 'xls,xlsx,xlsm',
			mimeTypes: 'application/vnd.ms-excel,application/x-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,.xls,.xlsx'
		},
	});
	
	templateUploader.on('fileQueued', function (file) {
		// 重新修改token,处理token过期问题
		this.options.server = OSS.APISERVER.FILE + '/rest/media/upload/' + OssUtil.getApiToken();
		$('#modalAjax').modal('show');
	});
	
	templateUploader.on('uploadSuccess', function (file, response) {
		$('#modalAjax').modal('hide');
		if (response) {
			
		}
		templateUploader.removeFile(templateUploader.getFile(file.id));
	});
	
	templateUploader.on('uploadError', function (file, response) {
		$('#modalAjax').modal('hide');
		console.info(response);
		OssUtil.bootboxAlert({message : '导入失败!'});
		templateUploader.removeFile(templateUploader.getFile(file.id));
	});
	
	$('.upload-excel', '#filter-updown-excel').on('click', function() {
		// 上传模板
		$(':file', '#filter-updown-excel').click();
	});
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在提供的代码中,中文乱码问题可能出现在以下两个地方: 1. 编码问题:您在使用 `web.UploadData` 方法发送 POST 请求时,将请求数据 `d` 定义为空字节数组 `Byte()`,这可能导致请求的编码方式不正确。您可以尝试将请求数据按照需要的编码方式进行编码,例如使用 `Encoding.UTF8.GetBytes` 方法将请求数据编码为 UTF-8。 2. 解码问题:在接收到服务器返回的响应数据后,使用 `Encoding.UTF8.GetString(res)` 将字节数组解码为字符串时,可能会遇到解码方式不正确的问题。可以尝试根据实际情况,将解码方式修改为与服务器返回数据一致的编码方式。 以下是修改后的代码示例: ```vb Function getSourceHtml(ByVal url As String) As String Dim result As String = "" Try Dim i As Integer = Int(Rnd(Now.Second) * 10 + 1) Dim web As New System.Net.WebClient() web.Headers.Add("Content-Type", "application/x-www-form-urlencoded") ' 构造要发送的数据 Dim postData As String = "your request data" Dim requestData As Byte() = System.Text.Encoding.UTF8.GetBytes(postData) ' 发送 POST 请求并接收响应数据 Dim responseData As Byte() = web.UploadData(url, "POST", requestData) ' 解码响应数据 result = System.Text.Encoding.UTF8.GetString(responseData) Catch ex As Exception MsgBox(ex.Message) End Try Return result End Function ``` 请注意,上述代码仅提供了解决中文乱码问题的一种可能方式。实际情况可能还需要根据具体的接口要求和数据编码方式进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值