Ajaxupload.js如何将查询参数传递给ashx文件 asp.net
Ajaxupload.js how to pass query param to ashx file asp.net
嗨,多年来我一直在尝试将参数传递给我的 ashx 页面
提前谢谢你
我目前正在使用此设置
上传
它的使用
jQuery有一个来自Andris Valums的插件http://valums.com/ajax-upload/你
代码示例
<script type="text/javascript">
$(function () {
var customerID = getURLParameter("id");
new AjaxUpload('#UploadButton', {
action: 'UploadHandler.ashx',
data: { "customerID":"44455" },
onComplete: function (file, response) {
$('#UploadStatus').html("<div class=success>file has been uploaded sucessfully</div>");
$("#UploadButton").hide();
},
onSubmit: function (file, ext) {
if (!(ext && /^(jpg|png)$/i.test(ext))) {
alert('Invalid File Format.');
return false;
}
//$('#UploadStatus').html("Uploading...");
}
});
});
</script>
网页端
<input type="button" id="UploadButton" class="btnReg charcoal" value="Upload Image" />
灰烬侧
public void ProcessRequest(HttpContext context)
{
folderPath = HttpContext.Current.Server.MapPath("DownloadedFiles");
customerID = context.Request.QueryString["customerID"];
//Uploaded File Deletion
if (context.Request.QueryString.Count > 0)
{
string filePath = folderPath + "//" + context.Request.QueryString[0].ToString();
deleteIMG(filePath, context.Request.QueryString[0].ToString());
}
//File Upload
else
{
//check if directory exist if not create one
var ext = Path.GetExtension(context.Request.Files[0].FileName);
var fileName = Path.GetFileName(context.Request.Files[0].FileName);
if (context.Request.Files[0].FileName.LastIndexOf("''") != -1)
{
fileName = context.Request.Files[0].FileName.Remove(0, context.Request.Files[0].FileName.LastIndexOf("''")).ToLower();
}
fileName = GetUniqueFileName(fileName, HttpContext.Current.Server.MapPath("DownloadedFiles/"), ext).ToLower();
string location = HttpContext.Current.Server.MapPath("DownloadedFiles/") + fileName + ext;
context.Request.Files[0].SaveAs(location);
context.Response.Write(fileName + ext);
context.Response.End();
}
}
我已经有
一段时间没有使用它了,但我认为它做了一个 POST,为了能够在您的处理程序中读取这些参数,您需要从中读取它们
context.Request.Params["paramname"]
相关文章:
- 如何播放部分音频文件
- 从桌面读取python文件时高亮显示代码
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何使用WCF服务和javascript表单post上传.doc文件
- 当包含另一个asp文件时,是否也包含所有引用的样式和脚本页面
- 如何在生成下载文件时显示加载动画
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- Javascript-如何读取json文件中的列并将其保存在Javascript数组中
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 如何在php文件中获取$.post-ajax传递的值
- 直接下载文件,而不是从window.open(url)
- 如何在android中使用phonegap将文件从一个文件夹移动/复制到另一个文件夹
- 使用压缩的JavaScript文件(不是运行时压缩)
- 在使用Polymer'加载所有json文件后执行方法;s的核心ajax
- 如何在elfinder插件(一个文件管理器插件)上获得上传前事件
- 通过将文件上载到ASHX处理程序来实现SSE(服务器发送的事件)
- Ajaxupload.js如何将查询参数传递给ashx文件 asp.net
- 如何将输入参数从 j 查询对话框传递到 asp.net 中的处理程序文件 (.ashx)
- Javascript使用ashx下载文件