Uploadify in ASP.Net
2020-12-13 05:25
标签:style class blog c code java 首先到Uploadify官网下载,然后在项目中添加相应引用。前台代码如下: 1.jquery.js js代码: html代码: 点击上传以后,会将数据提交到后台,交给uploadHandler.ashx处理。 一般处理程序ahsx会处理前台提交过来的数据,把图片保存到磁盘,然后返回图片的url给客户端进行预览。 一个简单的demo示范如何配置和使用Uploadify,安全性方面没有考虑。 Uploadify in ASP.Net,搜素材,soscw.com Uploadify in ASP.Net 标签:style class blog c code java 原文地址:http://www.cnblogs.com/fanyong/p/3736685.html
和分页类似,文件上传是web开发标配的技能之一。下面介绍Uploadify的配置和使用。一、配置
2.uploadify/jquery.uploadify.js
3.uploadify/uploadify.cssdiv id="">
img width="100px;" height="100px;" id="imgPriview" src="http://images4.c-ctrip.com/target/headphoto/portrait_180_180.jpg"
alt="" />
div>
input type="file" name="uploadify" id="uploadify" />
p>
a href="javascript:$(‘#uploadify‘).uploadify(‘upload‘,‘*‘);">上传a>| a href="javascript:$(‘#uploadify‘).uploadify(‘cancel‘)">
取消上传a>
p>
二、后台
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8";
HttpPostedFile file = context.Request.Files["Filedata"];
string uploadPath = context.Request.MapPath("/uploadedFiles/");
string fileName = file.FileName;
string imgUrl = "http://" + context.Request.Url.Authority + "/uploadedFiles/" + fileName;
if (file != null)
{
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
file.SaveAs(uploadPath + fileName);
context.Response.Write(imgUrl);
}
else
{
context.Response.Write("0");
}
}
上一篇:Python——标识符