久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在mvc中拖放文件

Drag and drop files in mvc(在mvc中拖放文件)
本文介紹了在mvc中拖放文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想通過拖放上傳文件.我編寫了如下代碼,但每次嘗試上傳文件時,都會顯示上傳失敗.誰能告訴我我錯在哪里?我想從外部源中拖動項目并將其上傳到我的文件夾中,但我無法做到.

I want to upload file using drag and drop. I have written code as below but every time I attempt to upload a file, it is showing upload failed. Can anyone tell me where I am wrong? I want to drag items from outer source and have it uploaded into my folder but I am not able to do it.

對于控制器:-

public ActionResult File()
{
   return View();
}

/// <summary>
/// The max file size in bytes
/// </summary>
protected int maxRequestLength
{
   get
   {
      HttpRuntimeSection section =
         ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;

      if (section != null)
         return section.MaxRequestLength * 1024; // Default Value
      else
         return 4096 * 1024; // Default Value
   }
}

/// <summary>
/// Checks if a file is sent to the server
/// and saves it to the Uploads folder.
/// </summary>
[HttpPost]
private void handleFileUpload()
{
   if (!string.IsNullOrEmpty(Request.Headers["X-File-Name"]))
   {
      string path = Server.MapPath(string.Format("~/Uploads/{0}", Request.Headers["X-File-Name"]));
      Stream inputStream = Request.InputStream;

      FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate);

      inputStream.CopyTo(fileStream);
      fileStream.Close();
   }
}

為了查看它是:-

<!DOCTYPE html>

<html>
<head runat="server">
    <title>Drag n' Drop File Upload</title>
    <link href="/Style.css" rel="Stylesheet" />
    <style>
body
{
    font: 12px Arial;
}

#dropZone
{
    border-radius: 5px;
    border: 2px solid #ccc;
    background-color: #eee;
    width: 250px;
    padding: 50px 0;
    text-align: center;
    font-size: 18px;
    color: #555;
    margin: 50px auto;
}

#dropZone.hover
{
    border-color: #aaa;
    background-color: #ddd;
}

#dropZone.error
{
    border-color: #f00;
    background-color: #faa;
} 
    </style>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>

    <script type="text/javascript">
        var dropZone;

        // Initializes the dropZone
        $(document).ready(function () {
            dropZone = $('#dropZone');
            dropZone.removeClass('error');

            // Check if window.FileReader exists to make 
            // sure the browser supports file uploads
            if (typeof(window.FileReader) == 'undefined') {
                dropZone.text('Browser Not Supported!');
                dropZone.addClass('error');
                return;
            }

            // Add a nice drag effect
            dropZone[0].ondragover = function () {
                dropZone.addClass('hover');
                return false;
            };

            // Remove the drag effect when stopping our drag
            dropZone[0].ondragend = function () {
                dropZone.removeClass('hover');
                return false;
            };

            // The drop event handles the file sending
            dropZone[0].ondrop = function(event) {
                // Stop the browser from opening the file in the window
                event.preventDefault();
                dropZone.removeClass('hover');

                // Get the file and the file reader
                var file = event.dataTransfer.files[0];

               @* if(file.size > @maxRequestLength {
                            dropZone.text('File Too Large!');
                        dropZone.addClass('error');
                        return false;*@
            //    // Validate file size
            //    if(file.size > <%=maxRequestLength%>) {
            //        dropZone.text('File Too Large!');
            //    dropZone.addClass('error');
            //    return false;
            /
                
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How do I write FileReader test in Jasmine?(如何在 Jasmine 中編寫 FileReader 測試?)
JS/HTML5 WebSocket: Connect without HTTP call(JS/HTML5 WebSocket:無需 HTTP 調用即可連接)
CSS: Repeat Table Header after Page Break (Print View)(CSS:分頁后重復表頭(打印視圖))
Put HTML head in another file(將 HTML 頭放在另一個文件中)
What is the real difference between the quot;headquot; and quot;headerquot; tag?(“頭和“頭之間的真正區別是什么?和“標題標簽?)
Header/Footer Layout with 100% Content Height in IE8(IE8 中具有 100% 內容高度的頁眉/頁腳布局)
主站蜘蛛池模板: 亚洲视频国产视频 | 欧美一区二区三区在线观看视频 | 操久久 | 久久99精品国产99久久6男男 | 亚洲va欧美va天堂v国产综合 | 草久久久| 免费午夜视频 | 日本三级播放 | 啪啪网页| 国产激情小视频 | 偷拍第一页 | 久久国产精品偷 | 免费簧片视频 | 国产成人福利在线观看 | 亚洲高清av在线 | 免费视频二区 | 成人毛片在线观看 | 精品福利一区 | 人人看人人干 | 免费成人高清在线视频 | 日韩一及片 | 精品国产91 | 亚洲国产一区二区三区四区 | 福利一区二区 | 黄a大片 | 美国一级毛片a | 国产精品国产a级 | 国际精品鲁一鲁一区二区小说 | 夜夜草| 久久久久久国产精品三区 | 91视频导航 | 91社区在线观看高清 | 一本色道精品久久一区二区三区 | 麻豆久久久9性大片 | 国产日韩中文字幕 | 青青草社区 | 亚欧精品一区 | 中文字幕av第一页 | 色资源在线| 国产大毛片 | 成人欧美一区二区三区在线观看 |