I have 2 files and one text area that has been created with node.js to handle the uploaded portion of the server I have used multer on node / express (4.0) to post on
I have been trying to keep the express space simple so far, just to test the fact that it is actually Works
/ // NODE JS Express
app Use (Multilter ({dest: __dirname + '/ public / uploads /', rename: function (field name, filename) {return file name; // replace (/ \ w + / g, '-'). ToLowerCase ) + Date now ()}})
/// ANGULAR
CmsApp.controller ("MyController", ['$ scope', '$ Location', '$ upload', function ($ scope, $ location, $ upload) {$ scope.title = $ place; //$scope.saveMiscs = function () {$ scope.submit = function () { Console.log ("saving miscs"); var file_1 = $ scope.formfile1; var file_2 = $ scope.formfile2; //console.log ('is file', JSON.stringify (file_reg all), "+" + JSON .stringify (file_statuto)); $ Scope.upload = $ upload.upload ({url: '/ api / misc / filupload1', //upload.php script, node.js File, or servlet URL file: file_1, // or list of files ($ files) only for html5) progress (function (evt) {console.log ('percent:' + parseInt (100.0 * evt.loaded / Evt.total))}} Success (Tasks (Data, Status, Header, Config) {// file has been successfully uploaded console.log ("Upload Complete:", Data);}); }; $ Realm Onfileselect = function ($ files) {$ scope.files = angular.copy ($ files); Console.log ($ scope.files); // my object returns) $ scope.setFiles = function (element) {$ scope. $ Apply (function ($ scope) {console.log (element.files); if (element.id == "form__file1") file_1 = Element.files; and if (element.id == "form__file2") file_2 = element .files;}); }; }];
/ / Eggler HTML
& lt; Form id = "modify_form" ng-submit = "submit ()" ng-controller = "microcontroller" enctype = "multipart / form-data" & gt; & Lt; Div class = "intro_detail" style = "margin-top: 36px;" & Gt; & Lt; Div class = "dotted blue" & gt; & Lt; / Div & gt; & Lt; Div class = "box_title" & gt; Document & lt; / Div & gt; Load file 1 here & lt; Br> & Lt; Input type = "file" id = "form_1_fld" class = "" name = "" onchange = "angular.element (this) .scope (.) SetFiles (this);" Ng model = "file_1" /> & Lt; Br> & Lt; Br> Load file 2 here & lt; Br> & Lt; Input type = "file" id = "form_2_fld" class = "" name = "" onchange = "angular.element (this) .scope (.) SetFiles (this);" Ng model = "file_1" /> & Lt; Div class = "dotted spacer_smile blue" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - sensory extension - & gt; & Lt; Div class = "form_viewport" & gt; & Lt; Div class = "full_container" & gt; & Lt; Label & gt; Write something here: & lt; / Labels & gt; & Lt; Br> & Lt; Textarea ng-model = "text_desc" id = "form__desc" & gt; & Lt; / Textarea & gt; & Lt; / Div & gt; & Lt; Div class = "clearfix" & gt; & Lt; / Div & gt; & Lt; Div class = "full_container" style = "text-align: center; margin-top: 50px;" & Gt; & Lt; Input type = "button" class = "plus_ cancel" value = "cancel" /> & Lt; Input type = "submit" class = "submit_save" value = "save" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - End view of the form - & gt; & Lt; / Form & gt; If I try to post a plain, which does not include the angular, then a simple multipart form with a "file" field takes the node / miller file and there is no problem. , But if I use this scenario to express in the game, then it seems that there is no file posted on the server.
Comments
Post a Comment