在web.config中添加:
<httpModules >
<add name="HttpUploadModule" type="Krystalware.SlickUpload.HttpUploadModule, Krystalware.SlickUpload" / >
</httpModules >
2、在项目中添加对Krystalware.SlickUpload.DLL的引用。
3、在页面上放控件:HtmlInputFile fileUpload;
4、后代码如下:
复制代码 代码如下:
private void RedirectToNewUpload()
{
Response.Redirect("PhotoInfo.aspx?uploadId=" Guid.NewGuid().ToString() "&action=" strViewType "&id=" BTSID);
}
private void Page_Load(object sender, System.EventArgs e)
{
...
UploadedFileCollection parts = HttpUploadModule.GetUploadedFiles();
if (Request.QueryString["uploadId"] == null)
RedirectToNewUpload();
...
}
private void btUpload_Click(object sender, System.EventArgs e)
{
UploadedFileCollection parts = HttpUploadModule.GetUploadedFiles();
string uppath = System.Configuration.ConfigurationSettings.AppSettings["UploadPath"];
try
{
if (parts != null)
{
foreach (UploadedFile part in parts)
{
if(part.ContentLength==0)
return;
if(File.Exists(uppath part.ClientName))
{
File.Delete(uppath part.ClientName);
}
part.SaveAs(uppath part.ClientName);
Byte[] FileByteArray = new Byte[part.ContentLength]; //图象文件临时储存Byte数组
FileStream fs = new FileStream(uppath part.ClientName, FileMode.Open);
fs.Read(FileByteArray,0,Convert.ToInt32(part.ContentLength));
fs.Close();
File.Delete(uppath part.ClientName);
//使用FileByteArray来保存得到的数据
}
RedirectToNewUpload();
}
标签:
asp.net,slickupload

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“asp.net slickupload 使用方法(文件上传)”

暂无“asp.net slickupload 使用方法(文件上传)”评论...