ASP.NET MVC-带图片的文件夹的用户管理(FTP?) [英] ASP.NET MVC - user managment of folder with pictures (FTP?)

查看:180
本文介绍了ASP.NET MVC-带图片的文件夹的用户管理(FTP?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发ASP.NET MVC应用程序,我需要一个包含图像(包括子文件夹)的每用户文件夹.我正在寻找一种允许管理此类图像库的简单方法(文件夹上传,单个图像上传,删除,显示).

i am developing an ASP.NET MVC application and I need a per-user folder with images (including subfolders). I am looking for an easy way to allow managment of such image galerries (folder upload, single image upload, delete, display).

图库本身不是应用程序的主要功能,也不必花哨(无需评论等)

The galery itself isnt the key function of the application and doesnt have to be fancy (no need for comments etc.)

现在,我正在考虑每个用户的FTP帐户.但是,

Right now, I am thinking about FTP account for each user. However,

  1. 有没有办法设置从c#代码到ftp文件夹的大小限制?
  2. 普通用户"将如何上传他的图像​​文件夹?是否有任何免费的插件来包装FTP图片管理?

还是有更简单的方法?

Or is there a more simpler way?

推荐答案

对于文件夹的大小,请使用代码

For the size of a folder, use code

Vb.Net

Dim Klasor As DirectoryInfo = New DirectoryInfo(Server.MapPath("~/Content"))
Dim Boyut As Decimal
For Each dr In Klasor.GetFiles
   Boyut += dr.Length
Next

将Vb转换为C#:(

DirectoryInfo Klasor = new DirectoryInfo(Server.MapPath("~/Content"));
    decimal Boyut = default(decimal);
    foreach (object dr_loopVariable in Klasor.GetFiles) {
        dr = dr_loopVariable;
        Boyut += dr.Length;
    }

关闭对http,使用授权成员资格上的文件夹的访问.查询只接受成员自己的文件夹.使用授权来读取和写入操作.

Close access to folders on http, Use authorizations membership. Query only accept members own folder. Use authorization to read and write operations..

示例读取:Vb.Net

Sample read : Vb.Net

    Function FileReturn() As FileResult
            Dim fi As New FileInfo(Server.MapPath("~/UserFiles/{UserID}/me.png"))
            Return File(fi.OpenRead, "image/png") 
//and for download Return File(fi.OpenRead, "image/png").FileDownloadName("me.png download") or Return File(fi.OpenRead, "image/png","meee")
        End Function

转换C#:

public FileResult FileReturn()
{
    FileInfo fi = new FileInfo(Server.MapPath("~/UserFiles/{UserID}/me.png"));
    return File(fi.OpenRead, "image/png");
    //and for download Return File(fi.OpenRead, "image/png").FileDownloadName("me.png download") or Return File(fi.OpenRead, "image/png","meee")
}

对vb.net代码感到抱歉

I'm sorry for vb.net code

这篇关于ASP.NET MVC-带图片的文件夹的用户管理(FTP?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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