AngularJS: upload and post photo as multi-part form data and get response -


I want to upload an image and post it on my server which the image should be forwarded to some APIs further It should get feedback. .

Perhaps I could use the scene with something like this:

   

And then the function controller would be something like:

  $ http ({method: 'POST', url: 'myAPIserver.php /', Data: "MyFoto =" + Photo, Header: {'Content-Type': 'Multiple / Form-Data'}});  

But this is not correct and I'm not sure how to complete it. The catch is that I am sending this photo to my PHP proxy first and from there I use Curl to request an API directly.

I hope I was clear enough to appreciate any suggestions, thanks

< P> I completed with the help of a custom instruction I received. You need a custom command to upload a file if you want to access files (NGModel does not work, see for more information).

Using the first link:

  & lt; Form ng-submit = "updateswith ()" name = "upload form" encrypt = "multipart / form-data" & gt; & Lt; Input name = "file" type = "file" id = "file" file-model = "fileToUpload" /> & Lt; Input name = "somethingineed" type = "submit" value = "upload" / & gt; & Lt; / Form & gt;  

You can upload the file went with $ scope.fileToUpload are, that everything makes it easy I pulled from the service went function on the first link and it Not used as a service because it makes me better in this way ...


Comments