• 大小: 5.18M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2020-12-26
  • 语言: C#
  • 标签: 上传  文件  

资源简介

bootstrap 文件上传

long lStartPos = 0;
            int startPosition = 0;
            int endPosition = 0;
            var contentRange = System.Web.HttpContext.Current.Request.Headers["Content-Range"];
            //bytes
            if (!string.IsNullOrEmpty(contentRange))
            {
                contentRange = contentRange.Replace("bytes", "").Trim();
                contentRange = contentRange.Substring(0, contentRange.IndexOf("/"));
                string[] ranges = contentRange.Split('-');
                startPosition = int.Parse(ranges[0]);
                endPosition = int.Parse(ranges[1]);
            }
            System.IO.FileStream fs;
            if (System.IO.File.Exists(saveFilePath))
            {
                fs = System.IO.File.OpenWrite(saveFilePath);
                lStartPos = fs.Length;
            }
            else
            {
                fs = new System.IO.FileStream(saveFilePath, System.IO.FileMode.Create);
                lStartPos = 0;
            }
            if (lStartPos > endPosition)
            {
                fs.Close();
                return false;
            }
            else if (lStartPos < startPosition)
            {
                lStartPos = startPosition;
            }
            else if (lStartPos > startPosition && lStartPos < endPosition)
            {
                lStartPos = startPosition;
            }
            fs.Seek(lStartPos, System.IO.SeekOrigin.Current);
            byte[] nbytes = new byte[512];
            int nReadSize = 0;
            nReadSize = file.InputStream.Read(nbytes, 0, 512);
            try
            {
                while (nReadSize > 0)
                {
                    fs.Write(nbytes, 0, nReadSize);
                    nReadSize = file.InputStream.Read(nbytes, 0, 512);
                }
                fs.Close();
                return true;
            }
            catch (Exception ex)
            {
                fs.Close();
                return false;
            }

资源截图

代码片段和文件信息

//------------------------------------------------------------------------------
// 
//    此代码是根据模板生成的。
//
//    手动更改此文件可能会导致应用程序中发生异常行为。
//    如果重新生成代码,则将覆盖对此文件的手动更改。
// 

//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Data.EntityClient;
using System.Data.objects;
using System.Data.objects.DataClasses;
using System.Linq;
using System.Runtime.Serialization;
using System.xml.Serialization;
using System.ComponentModel.DataAnnotations;

[assembly: EdmSchemaAttribute()]
namespace FileUploadDemo
{
    #region 上下文
    
    /// 
    /// 没有元数据文档可用。
    /// 

    public partial class MyBlogEntities : objectContext
    {
        #re

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        280  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\App_Start\FilterConfig.cs

     文件        605  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\App_Start\RouteConfig.cs

     文件        483  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\App_Start\WebApiConfig.cs

     文件      19456  2015-10-09 09:13  FileUploadDemo\FileUploadDemo\bin\FileUploadDemo.dll

     文件      44544  2015-10-09 09:13  FileUploadDemo\FileUploadDemo\bin\FileUploadDemo.pdb

     文件      45416  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\Microsoft.Web.Infrastructure.dll

     文件     374784  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\Newtonsoft.Json.dll

     文件     418776  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\Newtonsoft.Json.xml

     文件     180832  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Net.Http.dll

     文件      16480  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Net.Http.WebRequest.dll

     文件       5439  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Net.Http.WebRequest.xml

     文件     201824  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Net.Http.xml

     文件     138328  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.Helpers.dll

     文件      74208  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.Helpers.xml

     文件     506976  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.Mvc.dll

     文件     847872  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.Mvc.xml

     文件     264792  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.Razor.dll

     文件     365160  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.Razor.xml

     文件      41048  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.WebPages.Deployment.dll

     文件       2812  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.WebPages.Deployment.xml

     文件     204376  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.WebPages.dll

     文件      39512  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.WebPages.Razor.dll

     文件      17776  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.WebPages.Razor.xml

     文件     223301  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\System.Web.WebPages.xml

     文件      17504  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\zh-Hans\System.Net.Http.resources.dll

     文件      10336  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\zh-Hans\System.Net.Http.WebRequest.resources.dll

     文件      15472  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\zh-Hans\System.Web.Helpers.resources.dll

     文件      28768  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\zh-Hans\System.Web.Mvc.resources.dll

     文件      24688  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\zh-Hans\System.Web.Razor.resources.dll

     文件      12912  2015-08-21 13:05  FileUploadDemo\FileUploadDemo\bin\zh-Hans\System.Web.WebPages.Deployment.resources.dll

............此处省略413个文件信息

评论

共有 条评论