function _add_Content_Doc(){
if(Core_CheckNull("_input_content_name")){
if(Core_CheckNull("_input_content_content")){
var name = jq('#_input_content_name').val();
jq.ajaxFileUpload(
{url:'workflow.ao?mod=adddoc&type=0&dataguid='+input_content_dataguid+"&project="+input_content_project+"&name="+encodeURIComponent(name),
secureuri:false,fileElementId:'_input_content_content',dataType: 'json',
success: function (data, status){_add_Success_doc(data[0].guid,data[0].name,true);
alert("操作成功!");
jq('#_input_content_name').val("");
},error: function (data, status, e){alert("服务器忙,请稍后重试!");}
});
}else
alert("请选择文档!");
}
else
alert("请输入文件名称!");
}
参考网址:http://topic.csdn.net/u/20080912/16/068efe3a-5037-44d7-bd2e-8efadf3c0ac2.html
我今天用了这个上传控件文件是上传了,但是不知道为什么页面刷新了~试了几种方法都不行 ·页面每次上传都刷新
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Ajax File Uploader Plugin For Jquery</title>
<link href="screen.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload()
{
$("#loading")
.ajaxStart(function(){
$(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});
$.ajaxFileUpload
(
{
url:'Default2.aspx',
secureuri:false,
fileElementId:'fileToUpload',
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else
{
alert(data.msg);
}
}
},
error: function (data, status, e)
{
alert(e);
}
}
)
///return false;
}
</script>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
请上传一个文件: <br />
<img id="loading" src="image/1.gif" style="display:none;"/>
<input type="file" id="fileToUpload" name="fileToUpload" />
<input id="upload" οnclick="ajaxFileUpload()" value="上传" type="button" />
</div>
</form>
</body>
</html>
后台代码
protected void Page_Load(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
string msg = string.Empty;
string error = string.Empty;
if (files.Count > 0)
{
files[0].SaveAs(Server.MapPath("~/image/") + System.IO.Path.GetFileName(files[0].FileName));
msg = " 成功! 文件大小为:" + files[0].ContentLength;
string res = "{ error:'" + error + "', msg:'" + msg + "'}";
Response.Write(res);
Response.End();
}
}