C# 批量上傳

來源:互聯網
上載者:User

標籤:end   for   stat   play   code   response   檔案名稱   css   ror   

前台

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>批量上傳組件</title>
<link href="css/upload.css" rel="stylesheet" type="text/css" />
<script src="js/mootools.js" type="text/javascript"></script>
<script src="js/Swiff.Uploader.js" type="text/javascript"></script>
<script src="js/Fx.ProgressBar.js" type="text/javascript"></script>
<script src="js/FancyUpload2.js" type="text/javascript"></script>
<script src="js/UploadScript.js" type="text/javascript"></script>
</head>
<body>
<form action="upload.aspx?id=<%=Guid.NewGuid().ToString() %>" method="post" enctype="multipart/form-data" id="form-demo">
<div class="clearfix" style="width: 811px; margin: 5% auto; overflow: hidden; height: 207px; display: block;">
<fieldset id="demo-fallback" style="display: none;">
<legend>檔案上傳</legend>
<label for="demo-photoupload">
<input type="file" name="Filedata" />
</label>
</fieldset>
<div id="demo-status" class="hide">
<p>
<b id="demo-browse2" style="position: absolute; width: 80px; height: 26px;"></b><a href="javascript:;" id="demo-browse">
<img src="images/brow_file.png" /></a> | <a href="javascript:;" id="demo-clear">
<img src="images/file_del.png" /></a> | <a href="javascript:;" id="demo-upload">
<img src="images/upload_ico.png" /></a>
</p>
<div>
<strong class="overall-title"></strong>
<br />
<img src="images/progress-bar/bar.gif" class="progress overall-progress" />
</div>
<div>
<strong class="current-title"></strong>
<br />
<img src="images/progress-bar/bar.gif" class="progress current-progress" />
</div>
<div class="current-text"></div>
</div>
<ul id="demo-list"></ul>
</div>
</form>
</body>
</html>
<script type="text/javascript">
//js指令碼出錯的時候,不要給出任何提示。IE中如果js指令碼運行錯誤,右下角會出現小的歎號。
//加上這句,就不會出現任何提示了。
window.onerror = new Function("return true;");
</script>

後台:

//擷取檔案
HttpPostedFile httpFile = Request.Files["FileData"];
if (httpFile != null)
{
//擷取檔案名稱字
string fileName = httpFile.FileName;
//儲存檔案的路徑
string uploadPath = Server.MapPath("temp\\") + fileName;
//儲存檔案
httpFile.SaveAs(uploadPath);
Response.Write("檔案: " + uploadPath + " 上傳成功!");
}

C# 批量上傳

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.