How to change upload folder dynamicly

早过忘川 提交于 2019-12-07 23:44:37

问题


I'm using Backload file upload controller in my CustomerPortal build with MVC4. Within the CustomerPortal you can add SupportCalls. Within the SupportCall you can attach files. Every SupportCall has its own Guid.

The web.backload.default.config file contains the default upload location of the file "~/Files". However I want the file location to be different for every SupportCall. Like: "~/Files/d764578d-2f13-4820-bf1f-3d4427aedf22" where the Guid differs every time.

How can I achieve that?


回答1:


I found the answer to my question here : https://github.com/blackcity/Backload/wiki/Example-06

<form id="fileupload" 
      action="/Backload/UploadHandler" 
      method="POST" 
      enctype="multipart/form-data">

    <input type="hidden" 
           name="objectContext" 
           value="@Html.ViewBag.Id" />
</form>`

Just had to add a hidden field with the Id




回答2:


You're correct, objectContext is used for this purpose. One remark, you can set the objectContext client side as you do or server side within an event (e.g. IncomingRequest) or an extension. If you want to retrieve files (GET request) for a specific user, make sure to send the objectContext with the request too (url or form) or set it server side.



来源:https://stackoverflow.com/questions/18483332/how-to-change-upload-folder-dynamicly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!