jquery - Ajax and MVC 5 - Upload image binary by ajax -
I am writing code using knockoutjs and mvc5 where an image is selected and the image binary by ajax Is uploaded.
I can not really show much about image uploads, but I know that it works. The image is local to the browser and is stored in the binary visual model.
The problem is uploading the BVI to the Binary.
In my JavaScript, I am creating a post following:
var customer data = {customer name: self.CustomerName (), customer image: self Customer Image () ImageBinary (), Customer Job Number: self.CustomerJobNumber ()}; // If add, enable remaining area, edit ID and edit customer (window.location.hash == "#customer-add") {$. Content Type: 'Jason', Data: JSON Strej (Client Data), Success: Function (Data) {Ajax ({type: 'POST', url: "/ Customer / SaveNew", Content Type: 'Application / Jason' / * CODE * / var title = datatyal; var msg = data message; if (data.success == 0) {// as a gurran} other {// ticklish success window .hash = "#customer- Edit "+ Data. New customer. Customer; self. SAT client old (data .newCustomer); self.LoadCustomers ();}}, error: function (error) {warnings (c) Addiction); // tickling}}); } and I have it in my controller:
public class NewCustomerData {public string customer name {get; Set; } Public byte [] Customer Image {get; Set; } Public string client JobNumber {get; Set; }} [HTTPOST] Public Action Result Content {NewContrader Data} {// is Content} When I am running JavaScript, the customer image object I am sending is type Arraybuffer If I convert it to Uint8Array, then I can confirm that the content is there.
Its my solution was to convert ArrayBuffer into 64byte encoded string in JavaScript. I then modified the object to server side to accept string and voice.
Comments
Post a Comment