当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net slickupload 使用方法(文件上传)

asp.net slickupload 使用方法(文件上传)

2017年12月12日  | 移动技术网IT编程  | 我要评论

薄熙来案件,粤语流行曲,不接电话的你

在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();
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网