angular-upload
angular-upload copied to clipboard
data parameter doesnt work
<div
class="btn btn-primary btn-upload"
upload-button
url="/fileupload"
param="uploadedFile"
data="{{location}}"
on-success="onSuccess(response)"
>
Upload
</div>
writing like below doesn't work either
<div
class="btn btn-primary btn-upload"
upload-button
url="/fileupload"
param="uploadedFile"
data="location"
on-success="onSuccess(response)"
>
Upload
</div>
location is $scope.location. I tries to put an object there or string. In the server the body and.or query is empty
I'm noticing the same issue.
Never mind, it works fine. I am using Asp.net web api, and I was expecting to receive it as a parameter to my controller action, but it doesn't work that way. I did the following, and got it to work just fine:
I turn the scope data object that I want to send to the server into a JSON stringify'd equivalent:
scope.itemJSON = {
itemJSON: JSON.stringify(scope.item)
};
Then, in the HTML I bind to the ItemJSON object on the scope:
<div class="btn btn-primary btn-upload"
<!-- other properties -->
upload-button=""
data="itemJSON"
<!-- other properties -->
>
Upload
</div>
Then on the server Web Api controller in C#, I have this in the controller, using JSON.Net to deserialize the stringify'd value of the object back into it's concrete type:
var form = HttpContext.Current.Request.Form;
string itemJSON = form["itemJSON"];
DataTypeToDeserializeTo item = JsonConvert.DeserializeObject<DataTypeToDeserializeTo>(itemJSON);
Then I just use the item variable after that, as if it was passed to the web api action on the controller as a parameter to begin with.