Flash 上传器和 ASP.net MVC

发布于 2024-07-29 07:05:50 字数 452 浏览 6 评论 0原文

我有一个 Flash 上传组件,我想用它来上传多个文件。 我在 MVC 应用程序中使用它,我想要发生的是用户选择他们想要上传的文件,上传它们,然后显示一个页面,显示他们已上传的所有文件,以便他们可以添加描述并选择保存它们的位置,然后保存文件。

当文件上传时,闪存组件调用控制器来处理文件,这部分工作正常,我可以获取上传的文件并对其执行我喜欢的操作。 问题是,一旦控制器完成其工作,我就不能重定向到视图,因为它是调用控制器的闪存组件,而不是页面,所以当您尝试这样做时什么也不会发生。

我曾尝试将文件保存在会话中,然后在上传完成后使用 Flash 动作脚本中的一些代码转发给用户,但这不起作用,会话总是显示为空。 我还考虑过将文件实际保存到临时位置,然后在显示页面上仅列出临时位置中的所有文件,但这将涉及将文件保存两次,一次保存到临时目录,然后保存到实际位置用户想要放置它们,我认为这会很慢。

关于最好的方法有什么想法吗?

I have a flash upload component I want to use to upload multiple files. I'm using it in a MVC app and what I want to happen is that the user picks the files they want to upload, it uploads them and then displays a page showing all the files they have uploaded so they can add a description and select where to save them, and then save the files.

At the moment when files are uploaded the flash component calls a controller to process the files, this bit works fine, I can get the uploaded files and do what I like with them. The problem is is that I cannot just redirect to a View once the controllers done its work, because its the flash component calling the controller, not the page and so nothing happens when you try and do that.

I had attempted to save the files in the session and then forward the user on completion of the upload using some code in the flash actionscript, this however does not work, the session always turns up null. I had also considered actually saving the files to a temp location and then on the displaying page just listing all files in the temp location, but this is then going to involve saving the files twice, once to the temp directory and then to the actual place the user wants to put them, which I assume will be slow.

Any thoughts on the best way to do this?

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

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

发布评论

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

评论(1

2024-08-05 07:05:50

您的网站是否使用基于 cookie 的身份验证? 如果是这样,那么 Flash 上传程序需要在上传时包含身份验证 cookie,否则上传将被视为来自新用户 - 这将解释会话状态中的空值。 如果您无法让 flash 发布 cookie,那么您必须在上传 URL 中识别用户。

您应该将会话状态保持在最低限度,甚至最好根本不使用它,因此在其中存储大量数据(例如图像)是一个坏主意。

通过我们的应用程序,我们将所有上传的文件保存到数据库中,然后为它们提供一个唯一的 Guid,然后用于稍后检索/显示它们。 在数据库中,图像可以与用户关联,并且在您的情况下被标记为刚刚上传,以便当您将用户重定向到附加信息页面时,您知道要显示哪些图像。

但这将涉及到
将文件保存两次,一次保存到
temp目录然后到实际的
用户想要放置它们的地方

位置相对于文件在服务器上的保存位置,您不应允许用户确定文件的保存位置。

Is your site using cookie based authentication? If so then the flash uploader needs to include the authentication cookie when uploading otherwise the upload will be seen as coming from a new user - this would explain your null values in the session state. If you are unable to get flash to post the cookie then you'll have to identify the user within the upload URL.

You should keep session state to a minimum or even better not use is at all so storing large amounts of data such as images in it is a bad idea.

With our applications we save all uploaded files to the database and then give them a unique Guid that is then used to retrieved/display them later. Within the database images could be associated with a user and in your case be marked as just uploaded so that when you redirect the user to the additional information page you know which images to display.

but this is then going to involve
saving the files twice, once to the
temp directory and then to the actual
place the user wants to put them

In relation to where the files are saved on the server you should not be allowing the user to determine where the files are saved.

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