uploadify 将查询传递给通用处理程序
在这部分停留了几天,我仍然无法将任何查询字符串传递给通用处理程序。
我的代码如下:
1st:查询字符串被传递到Upload.aspx。我在页面加载部分检索它:
My Upload.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
int userId = Convert.ToInt32(Request.QueryString["userid"]);
int upload = Convert.ToInt32(Request.QueryString["upload"]);
int childId = Convert.ToInt32(Request.QueryString["childid"]);
}
My Upload.aspx
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': 'Upload.ashx',
'cancelImg': 'uploadify/cancel.png',
'auto': true,
'multi': true,
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
'queueSizeLimit': 90,
'sizeLimit': 4000000,
'buttonText': 'Choose Images',
'folder': '/uploads',
'onAllComplete': function(event, queueID, fileObj, response, data) {
}
});
});
我的 upload.ashx
public void ProcessRequest(HttpContext context)
{
try
{
HttpPostedFile file = context.Request.Files["Filedata"];
Global.myDBManager.ConnectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
Global.myDBManager.DataProviderType = DBMgr.DataProvider.MySql;
Global.myDBManager.Connect();
int id = 1 + Convert.ToInt32(Global.myDBManager.ExecuteScalar("Select id from picture order by picture_id desc limit 1"));
Global.myDBManager.ExecuteScalar("Insert into image(picture_id,user_id) VALUE('" + id + "', '" + userId + "')");
file.SaveAs("C:\\" + id.ToString() + file.FileName);
context.Response.Write("1");
}
catch (Exception ex)
{
context.Response.Write("0");
}
}
如何将查询传递到 upload.ashx?其中 userId 是我试图传递的查询。
提前致谢 !
Been stuck at this part for a few days that i still could not pass any query string to generic handler.
my code is as follows:
1st: query string is passed into Upload.aspx. and i retrieve it in the page load section:
My Upload.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
int userId = Convert.ToInt32(Request.QueryString["userid"]);
int upload = Convert.ToInt32(Request.QueryString["upload"]);
int childId = Convert.ToInt32(Request.QueryString["childid"]);
}
My Upload.aspx
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': 'Upload.ashx',
'cancelImg': 'uploadify/cancel.png',
'auto': true,
'multi': true,
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
'queueSizeLimit': 90,
'sizeLimit': 4000000,
'buttonText': 'Choose Images',
'folder': '/uploads',
'onAllComplete': function(event, queueID, fileObj, response, data) {
}
});
});
My upload.ashx
public void ProcessRequest(HttpContext context)
{
try
{
HttpPostedFile file = context.Request.Files["Filedata"];
Global.myDBManager.ConnectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
Global.myDBManager.DataProviderType = DBMgr.DataProvider.MySql;
Global.myDBManager.Connect();
int id = 1 + Convert.ToInt32(Global.myDBManager.ExecuteScalar("Select id from picture order by picture_id desc limit 1"));
Global.myDBManager.ExecuteScalar("Insert into image(picture_id,user_id) VALUE('" + id + "', '" + userId + "')");
file.SaveAs("C:\\" + id.ToString() + file.FileName);
context.Response.Write("1");
}
catch (Exception ex)
{
context.Response.Write("0");
}
}
how do i pass the query into upload.ashx? where userId is the query that im trying to pass.
thanks in advance !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 ProcessRequest 方法中使用它。您可以使用 Context.Request 来获取查询字符串参数。
确保您已在应用程序
web.config
中完成 url 映射。例如,
这个链接可能会给您一些关于编写通用处理程序的想法。
Use this in
ProcessRequest
method. You can useContext.Request
to get the querystring parameters.Make sure you have done url mapping in your application
web.config
.E.g.
This link might give you some idea on writing generic handlers.