Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

flow.js upload file on click passing null

Trying to pass the file to controller public ActionResult Save(IEnumerable files) but I keep passing null.

$scope.flow = {}
    $scope.uploadme = function (e) {angular.forEach(e, function (flow) {
                        var fd = new FormData();
                        fd.append("file", flow);
                        $http.post("/Save", fd, {
                            withCredentials: true,
                            headers: { 'Content-Type': undefined },
                            transformRequest: angular.identity
                        })
                    });
                }




        #########################################  Client html
  <div flow-init flow-name="obj.flow"
                                                flow-file-success="$file.msg = $message">
 <input type="file" name="xlfile"  flow-btn />
                                                <input type="button" value="Click Me" ng-click="uploadme($flow)">


                                                <table>
                                                    <tr ng-repeat="file in $flow.files">
                                                        <td>{{$index+1}}</td>
                                                        <td>{{file.name}}</td>
                                                        <td>{{file.msg}}</td>

                                                    </tr>
                                                </table>
                                                I have uploaded files: #{{flow.files.length}}


                                            </div>

Open in new window

Avatar of BigRat
BigRat
Flag of France image

Well $flow is defined in scope as an empty object.  Somewhere it should get loaded with an array of file objects, called files, which should be have fields name and msg.

The way it stands at the moment, when you press the button "Click me", the empty object is passed fo uploadme which will do absolutely nothing.

So, how do we select "files" and "msgs" to put them into an array?

(BTW why enumerate $flow (=e in uploadme), when you append $flow to fd???)
Avatar of Seven price

ASKER

Good question answer. Not to sure. Maybe something like e.file.target. do you have example with my current code would help me understand.
I haven't the slightest idea of what you are trying to achieve. You might try starting from the top. If you are trying to pick things out of a list, you'll need to initailze the list first. And don't make the pick list the target list at the same time!
I am just trying to upload a file to my directory. Thats all.
ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is a try. I will implement this and let you know before I close. Thank you for lending out your hand of suggestions.
I tried to close it and give points but there is no way to give points. Nothing is showing
Let tagit close it.

Anyway did you implement one of my suggestions?
Ng upload worked great for me.  Thanks again.