*Hi*

*i try to save data into SQL database i can save all data but i can't get 
any data from input type="file" and i don't know what is the problem here ?*

*View Code:*

    <form method="post" ng-submit="saveInvoice(); invoice={}">
        <table class="table table-striped table-bordered" dir="rtl">
            <tr>
                <th class="text-center">العميل</th>
                <th class="text-center">تاريخ الفاتورة</th>
                <th class="text-center">الإجمالى</th>
                <th>ملف</th>
                <th></th>
            </tr>
            <tr>
                <td align="center" style="vertical-align:middle;">
                    <div>
                        @(Html.Kendo()
                              .AutoComplete()
                              .Name("Customers")
                              .DataTextField("ContactName")
                              .Events(events => 
events.Select("CustomerSelect"))
                              .MinLength(1)
                              .HtmlAttributes(new { style = "width:450px; 
font-weight:bold", ng_model = "invoice.ContactName" })
                              .Placeholder("إكتب جزء من إسم العميل")
                              .Filter("contains")
                              .Delay(1)
                              .DataSource(source =>
                              {
                                  source.Custom()
                                        .ServerFiltering(true)
                                        .ServerPaging(true)
                                        .Type("aspnetmvc-ajax") //Set this 
type if you want to use DataSourceRequest and ToDataSourceResult instances
                                        .Transport(transport =>
                                        {
                                            
transport.Read("Virtualization_Customer_Read", "Home");
                                        })
                                        .Schema(schema =>
                                        {
                                            schema.Data("Data") //define 
the 
[data](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data)
 
option
                                                  .Total("Total"); //define 
the 
[total](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total)
 
option
                                        });
                              })
                              .Virtual(v => 
v.ItemHeight(26).ValueMapper("cusvalueMapper"))
                        )

                    </div>
                </td>
                <td style="display:none;">
                    @Html.TextBox("CustomerID", null, new { ng_model = 
"invoice.CustomerID" })
                </td>
                <td align="center" style="vertical-align:middle;">
                    @(Html.Kendo()
                          .DatePicker()
                          .Format("yyyy-MM-dd")
                          .Name("OrderDate")
                          .HtmlAttributes(new { style = "width:150px; 
font-weight:bold; text-align:center", ng_model = "invoice.OrderDate" })
                    )

                </td>
                <td align="center" style="vertical-align:middle; 
width:175px; font-weight:bold">
                    {{calculate_grand_total() | currency}}
                    @Html.TextBox("Total_Item", null, new { ng_model = 
"invoice.Total = calculate_grand_total()", style = "display:none;" })
                </td>
                <td>
                    <input type="file" ng-model="invoice.File" /> // i 
can't get any data from this input it come null in api controller
                </td>
                <td align="center" style="vertical-align:middle;">
                    <input ng-disabled="invoice.CustomerID == '' || 
invoice.OrderDate == null || invoice.Total == 0.00" type="submit" 
name="submitbtn" value="حفظ الفاتورة" class="btn btn-success" 
style="font-weight:bold;" />
                </td>
            </tr>
        </table>
    </form>

*problem here:*

                <td>
                    <input type="file" ng-model="invoice.File" /> // i 
can't get any data from this input it come null in api controller
                </td>

*Angularjs Code:*

(function () {
    var app = angular.module('jqanim', []);

    app.controller('InvoiceController', function ($scope, $http) {

        $scope.invoice = { ContactName: "عميل نقدى" };

        $scope.saveInvoice = function () {
            $http.post("/api/customerService/SaveInvoice", $scope.invoice)

                .success(function (data) {
                                        $scope.invoice = { ContactName: 
"عميل نقدى" };

                    alertify.set('notifier', 'position', 'top-left');
                    alertify.success('تم حفظ الفاتورة', 3);
                             })
                .error(function (data) {
                    alertify.set('notifier', 'position', 'top-right');
                    alertify.error('يوجد خطأ', 2);
                    return;
                });
        };
     });
})();

*when i press save i got it empty as image below:*

<https://lh3.googleusercontent.com/-WgEYFMW5Kl4/VX4pZU6S7NI/AAAAAAAABbE/5uZzYlLDDSw/s1600/Untitled.png>


*view Model Code:*


public class Order_VM    
{
        public Order_VM()
        {
            Order_Details = new HashSet<Order_Details_VM>();
        }

        public int OrderID { get; set; }

        public int? CustomerID { get; set; }

        public string ContactName { get; set; }

        public int? SupplierID { get; set; }

        public int? EmployeeID { get; set; }

        [Column(TypeName = "date")]
        public DateTime? OrderDate { get; set; }

        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = 
"{0:c}")]
        public float Total { get; set; }

        public HttpPostedFileBase File { get; set; } // here for file

        public virtual ICollection<Order_Details_VM> Order_Details { get; 
set; }
    }


*so please how can i get data from file upload in api controller to let me 
upload file and save data to database ?*

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to