導航:首頁 > 版本升級 > net超炫的多文件上傳源碼

net超炫的多文件上傳源碼

發布時間:2023-02-01 15:12:45

Ⅰ asp.net用多線程上傳大文件(500MB~2G)

大文件上傳,進度條效果推薦你用uploadify插件結合asp.net來做,這個的實現網上有例子,我這里自己也做了一個,上傳頁面是uploadify3.2/index.html ,上傳處理程序是upload.ashx。用vs2010製作,需要framework4.0環境的支持。 經測試打文件上傳功能已經穩定,,進度條顯示效果友好。

最近打算把原來的asp網站改成asp.net的,所以做了這個,你可以參考一下。

Ⅱ Asp.net 批量上傳附件如何實現 謝謝,

FileUpload實現單圖片上傳,如果想多圖片上傳,你試試這個:
<tr>
<td align="right" valign="top">
試卷照片:
</td>
<td align="left">
<div id="_container">
<input id="File1" type="file" name="File" runat="server" size="10" />
</div>
</td>
<td align="left" valign="bottom">
<input type="button" value="添加" onclick="addFile()" />
</td>
</tr>
addFile()源碼:
//多文件上傳,動態生成多個上傳控制項
function addFile() {
var div = document.createElement("div");
var f = document.createElement("input");
f.setAttribute("type", "file");
f.setAttribute("name", "file");
f.setAttribute("size", "10");
div.appendChild(f);
document.getElementById("_container").appendChild(div);
}

後台頁面調用:
#region 上傳添加圖片的方法
/// <summary>
/// 上傳添加圖片的方法
/// </summary>
/// <param name="nId">關聯id</param>
private static void UploadAndAddPicTures(int nId)
{
LMS.BLL.TRAIN_Pictrue PictrueBLL = new LMS.BLL.TRAIN_Pictrue();
List<LMS.Model.TRAIN_Pictrue> list = new List<LMS.Model.TRAIN_Pictrue>();
//遍歷File表單元素
HttpFileCollection files = HttpContext.Current.Request.Files;
for (int iFile = 0; iFile < files.Count; iFile++)
{
//檢查文件擴展名字
HttpPostedFile postedFile = files[iFile];
string fileName;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName.ToLower() != "")
{
LMS.Model.TRAIN_Pictrue Pictrue = new LMS.Model.TRAIN_Pictrue();
string scurTypeName = fileName.Substring(fileName.LastIndexOf("."));
//初始化原圖物理路徑
string sGuid_phy = Guid.NewGuid().ToString();
string sUrl_phy = ConfigurationManager.AppSettings["PhysicsObjectPath"].ToString() + sGuid_phy + scurTypeName;
//初始化縮略圖物理路徑
string sGuid_web = Guid.NewGuid().ToString();
string sUrl_web = ConfigurationManager.AppSettings["PhysicsObjectPath"].ToString() + sGuid_web + scurTypeName;
postedFile.SaveAs(sUrl_phy);//保存原圖
PTImage.ZoomAuto(postedFile, sUrl_web, 100, 100, "", "");//生成縮略圖,並保存
//保存原圖虛擬路徑到資料庫
Pictrue.path = ConfigurationManager.AppSettings["WebObjectPath"].ToString() + sGuid_phy + scurTypeName;
//保存縮略圖虛擬路徑到資料庫
Pictrue.shrinkpath = ConfigurationManager.AppSettings["WebObjectPath"].ToString() + sGuid_web + scurTypeName;
Pictrue.parid = nId;
Pictrue.tables = "TRAIN_Hotel_MonthExam";
list.Add(Pictrue);
}
}
PictrueBLL.Add(list);
}
#endregion
希望對你有幫助!

Ⅲ asp.net 一般處理程序(ashx)如何多次接收上傳文件(多文件批量上傳)

Like
this

比如源前台有3個INPUT:
然後後台:
HttpFileCollection
files
=
HttpContext.Current.Request.Files;
//這個files裡面就是你上傳文件的集合。遍歷即可。

Ⅳ .net實現文件上傳到伺服器

1、前端界面十分簡單,只是放一個file類型的和一個按鈕,並且為這個按鈕添加點擊事件(btnUpLoad_Click),如下圖:

protectedvoidbtnUpLoad_Click(objectsender,EventArgse)
{
//取出所選文件的本地路徑
stringfullFileName=this.UpLoad.PostedFile.FileName;
//從路徑中截取出文件名
stringfileName=fullFileName.Substring(fullFileName.LastIndexOf()+1);
//限定上傳文件的格式
stringtype=fullFileName.Substring(fullFileName.LastIndexOf(.)+1);
if(type==doc||type==docx||type==xls||type==xlsx||type==ppt||type==pptx||type==pdf||type==jpg||type==bmp||type==gif||type==png||type==txt||type==zip||type==rar)
{
//將文件保存在伺服器中根目錄下的files文件夾中
stringsaveFileName=Server.MapPath(/files)++fileName;
UpLoad.PostedFile.SaveAs(saveFileName);
Page.ClientScript.RegisterStartupScript(Page.GetType(),message,<scriptlanguage='javascript'defer>alert('文件上傳成功!');</script>);

//向資料庫中存儲相應通知的附件的目錄
BLL.news.InsertAnnexBLLinsertAnnex=newBLL.news.InsertAnnexBLL();
AnnexEntityannex=newAnnexEntity();//創建附件的實體
annex.AnnexName=fileName;//附件名
annex.AnnexContent=saveFileName;//附件的存儲路徑
annex.NoticeId=noticeId;//附件所屬「通知」的ID在這里為已知
insertAnnex.InsertAnnex(annex);//將實體存入資料庫(其實就是講實體的這些屬性insert到資料庫中的過程,具體BLL層和DAL層的代碼這里不再多說)
}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(),message,<scriptlanguage='javascript'defer>alert('請選擇正確的格式');</script>);
}
}

Ⅳ 求C#.NET 以上超大文件上傳和斷點續傳伺服器的實現

我以前寫過來這樣的例子,用自的Socket TCP協議,多大文件都可以,只是時間問題,主要是斷點續傳,傳輸文件時,客戶端請求一下伺服器端,伺服器端返回當前文件的已經接收的位元組大小,客戶端收到伺服器端已經接收的位元組大小時,就通過指針移動你要傳輸的文件位元組位置為接收的位元組大小的位置,繼續通過Socket傳輸,無論是Http還是什麼原理差不多

Ⅵ ASP.NET中怎麼實現多文件同時上傳要求點瀏覽的時候可以一次性多選文件

多放幾個fileupload
後台用Request.Files獲取,這是你上傳文件的集合。

閱讀全文

與net超炫的多文件上傳源碼相關的資料

熱點內容
如何更改考勤表上的數據 瀏覽:606
除了編程還有什麼技術 瀏覽:64
為什麼程序員討厭中文編程 瀏覽:338
數控車床編程g40是什麼意思 瀏覽:782
人們花錢為什麼逐漸網路化 瀏覽:272
如何用編程辦理電信業務 瀏覽:189
數控磨床小圓弧怎麼編程 瀏覽:390
桐鄉編程貓在哪裡 瀏覽:69
同一文件夾存儲大量文件 瀏覽:126
chrome修改js 瀏覽:842
用pad怎麼發word文件怎麼打開 瀏覽:465
哪個網站有幼 瀏覽:299
航班APP哪個最好 瀏覽:590
網路原創如何增強教育活力 瀏覽:527
蘋果第三方打開文件 瀏覽:310
蘋果電腦桌面移除的文件夾怎麼恢復 瀏覽:292
在文件名前添加字元 瀏覽:424
javaexcel導出控制項 瀏覽:484
怎麼樣粉碎文件 瀏覽:798
谷歌網站怎麼更新 瀏覽:934

友情鏈接