ASP.NET MVC 2 的文件管理器?

发布于 2024-09-14 02:27:38 字数 1284 浏览 4 评论 0原文

我正在尝试找到一种在 mvc 2 应用程序中实现文件管理器功能的方法。我已经研究了 jquery 等来实现这一点。我已经能够仅使用输入文件按钮等实现简单的上传/下载功能,并且我还尝试了jquery文件树(http://abeautifulsite.net/blog/2008/03/jquery-file-tree/),但我不知道如何连接文件树功能与我想要的下载、上传和删除功能。尽管文件树可以工作,但如果您单击文件,它所做的只是显示带有文件名的警报。我不知道如何融入这个。

我想要像左边有文件夹的树,然后右边有文件,可以选择文件,然后下载或删除。我想上传功能不会有问题,因为我可以将其分开,然后重新加载页面以便文件树更新。尽管理想情况下我希望它保持相同的选择。

有人知道如何做到这一点吗?

如果没有(或者无论如何),如果有人知道在 ajax/jquery 等中具有这些功能(包括上传/下载/删除)的开源文件管理器或实际上与 mvc2 兼容的类似文件,我也将非常感激。原因是我不想用 Web 表单版本搞乱 mvc 应用程序,我确实知道这一点。

编辑:

这是调用 fileTree 函数的代码:

<script type="text/javascript">
    $(document).ready(function () {

        $('#JQueryFTD_Demo').fileTree({

            script: 'Home/JqueryFileTree',
            expandSpeed: 1000,
            collapseSpeed: 1000,
            multiFolder: true
        }, function (file) {
            alert(file); //This shows the name of the file if you click it
        });
    });
</script>

我无法很好地读取 fileTree 函数来获取文件名的来源(它如何进入此处的变量“file”),以及如何挂钩该函数对文件执行不同的操作,例如删除、下载等。同样,我对 jquery 非常陌生,所以这有点超出我的想象,我只需要一个文件管理器功能来执行这些操作并且与 MVC 兼容思维方式(即不是基于Web表单),所以任何其他关于“预烘焙代码”的建议都可以,我不必理解它,只需使用它,然后我就可以按照自己的节奏学习jquery: -)。

I'm trying to find a way to implement file manager functionality in an mvc 2 application. I've looked at jquery etc for ways of doing this. I have been able to implement a simple upload/download functionality with just an input file button and so on, and I have also tried out jquery File Tree (http://abeautifulsite.net/blog/2008/03/jquery-file-tree/), but I have no idea how to connect the file tree functionality with the download, upload and delete functionality I want. Even though the file tree works, all it does if you click on a file is to show an alert with the name of the file. I don't know how to hook into this.

I would like something like the tree to the left with folders, and then the files to the right, with possibilites to select a file and then download or delete. The upload functionality I guess would be no problem, since I could just have that separate, and then reload the page so that the file tree updates. Although ideally I would have liked it to stay at the same selection.

Anyone have any ideas how to do this?

If not (or anyway) I would also very much appreciate if anyone knows of an open source file manager with these features (including upload/download/delete) in ajax/jquery or the like that is actually compatible with mvc2. The reason is I don't want to mess up the mvc application with web forms versions, which I do know of.

EDIT:

Here's the code that calls the fileTree function:

<script type="text/javascript">
    $(document).ready(function () {

        $('#JQueryFTD_Demo').fileTree({

            script: 'Home/JqueryFileTree',
            expandSpeed: 1000,
            collapseSpeed: 1000,
            multiFolder: true
        }, function (file) {
            alert(file); //This shows the name of the file if you click it
        });
    });
</script>

I can't read the fileTree funcion well enought to get where the file name is coming from (how it gets into the variable "file" here), and how I could hook into that to do different things with the file, such as deleting, downloading etc. Again, I'm very new to jquery so this is a bit above my head, I just need a file manager function that does these things and is compatible with the MVC way of thinking (i.e. not web forms based), so any other suggestions for "pre-baked code" would be fine, I don't have to understand it, just use it, and then I can learn jquery at my own pace :-).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蒲公英的约定 2024-09-21 02:27:38

If you are able to alert the selected filename you could send an AJAX request to a controller action passing this filename so that the server can take care of deleting the file. As far as downloading is concerned you could use a regular hyperlink to a controller action that will write the file contents in the response stream.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文