如何使用asp.net mvc上传多个文件时显示文件上传信息 [英] How to display file uploading information while uploading multiple file using asp.net mvc

查看:55
本文介绍了如何使用asp.net mvc上传多个文件时显示文件上传信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

///............View................// 
@model IEnumerable<httppostedfilebase>
@{
    Layout = "~/Views/Shared/_LayoutMaster.cshtml";
}
<div>
 @using (Html.BeginForm("UploadImage", "Home", FormMethod.Post, new {
                                              enctype = "multipart/form-data" }))
 {
<div style="float:left; width:300px;padding:10px">
                    <input type="file" name="files" id="file" multiple="multiple" /></div>
                <div style="float:left; width:300px;padding:10px">
                  <input type="submit" name="Upload" value="Upload" />
                </div>
   }
</div>










///......HomeContorller action........./// 
public ActionResult UploadImage(IEnumerable<httppostedfilebase> files)
        {           
            Flickr flickrObject = FlickrManager.GetAuthInstance();
            flickrObject.InstanceCacheDisabled = true;           
            try
            {
                if (files != null)
                {
                   foreach (HttpPostedFileBase file in files)
                    {              
                      string photoid = flickrObject.UploadPicture(file.InputStream, name, title, description, tag, false, false, false, ContentType.Photo, SafetyLevel.None,HiddenFromSearch.Visible);                             
                    }          
            return View("Uploader");
        }</httppostedfilebase></httppostedfilebase>

推荐答案

为此您必须使用启用Javascript的图像上传框架。您可以使用 DropzoneJS。



什么是DropzoneJS?



DropzoneJS是一个开源库,提供drag'n'drop文件上传图片预览。



我写了一篇关于此的文章。请阅读更多信息。



使用ASP.net MVC DropzoneJS



dropzonejs主页



更新



请尝试如下,如果您有任何问题,请告诉我。



For that you have to use Javascript enabled image uploading framework.You can use DropzoneJS.

What is DropzoneJS ?

DropzoneJS is an open source library that provides drag'n'drop file uploads with image previews.

I have written an article about this.Please read it for more info.

DropzoneJS with ASP.net MVC

dropzonejs Home

UPDATE

Please try is as below and let me know if you have any issues.

Dropzone.options.uploadDropzone = {
    paramName: "file1",
    maxFilesize: 200,
    maxThumbnailFilesize: 10,
    success: function(file, response){
      alert('success');
  },
error: function(file, response){
  alert('error');
  },
};


这篇关于如何使用asp.net mvc上传多个文件时显示文件上传信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆