使用MVC C#上传文件夹 [英] Folder upload using MVC C#

查看:58
本文介绍了使用MVC C#上传文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,
I want to upload entire folder using ASP.net C#.Mvc.
Please help me..





我的尝试:



我试过上传多个文件。



What I have tried:

I hace tried multiple files upload.

推荐答案

你没有上传文件夹。您可以单独上传文件夹中的文件。



根据您使用的浏览器和版本,您可能只能一次只执行一个文件。



您没有描述您遇到的任何特定问题或错误消息,也没有显示您用来挑选文件并将其上传到客户端上的代码服务器端,所以几乎不可能告诉你可能出现的问题。
You don't upload a folder. You upload the files in the folder, individually.

Depending on the browser and version you're using, you may be limited to only doing one file at a time.

You didn't describe any particular problem or error messages you're getting nor showed the code you're using to pick the files and upload them on the client and the server side, so it's pretty much impossible to tell you what may be wrong.


如解决方案中所述,您需要上传一个需要上传的文件。归档该文件夹,然后上传为文件。为此,您需要先要求用户归档文件夹 - 否则请使用脱机软件执行此操作并将文件上载到服务器。



第一种方法不起作用,浏览器不允许选择文件夹。有一个< input type =file目录/> ,但不保证能够正常工作。要了解更多信息,您需要了解输入的工作原理,

如何从HTML输入类型文件或任何其他方式获取文件夹目录? - 堆栈溢出 [ ^ ]

HTML输入类型属性 [ ^ ]

使用来自Web应用程序的文件MDN [ ^ ]

HTML页面中的目录选择器 - 堆栈溢出 [ ^ ]



如果您使用第二种方法,那么您可以使用以下类来压缩文件夹, ZipFile Class(System.IO.Compression) [ ^ ]。
As mentioned in Solution, you need to upload have a file that needs to be uploaded. Archive that folder and then upload as a file. For this, you need to ask the users to archive the folders first — otherwise use an offline software to do that and upload the files to server.

First method will not work, browsers will not allow selection of folders. There is a <input type="file" directory /> but that is not guaranteed to work. To know more on this, you need to understand how that input works,
How to get folder directory from HTML input type "file" or any other way? - Stack Overflow[^]
HTML input type Attribute[^]
Using files from web applications | MDN[^]
Directory Chooser in HTML page - Stack Overflow[^]

If you use second method then you can use the following class to zip a folder, ZipFile Class (System.IO.Compression)[^].


这篇关于使用MVC C#上传文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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