问题
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