aravind
aravind

Reputation: 1

how to save an image into a separate folder

hi i am new to angular js and javaScript. i want to save an image into a folder after i browsed that image from another folder or desktop,iam not getting how to do,will u suggest me how to do that. can i use code like this and js will like this

$scope.uploadFile = function(element) {   
                            var data = new FormData();
                            data.append('file', $(element)[0].files[0]);
                            jQuery.ajax({
                                  url: 'H:\images',
                                  type:'post',
                                  data: data,
                                  contentType: false,
                                  processData: false,
                                  success: function(response) {
                                      alert("Success upload");
                                  console.log(response);
                                  },
                                  error: function(jqXHR, textStatus, errorMessage) {
                                  alert('Error uploading: ' + errorMessage);
                                  }
                             });   
                            };

Upvotes: 0

Views: 55

Answers (1)

Tom Anderson
Tom Anderson

Reputation: 460

JavaScript isn't able to edit or create files on a server or computer, for security reasons. Since JavaScript is client-side (running on a client's computer), someone could easily edit and do things to a file on a computer or server. If you are looking to save and move files, consider using a server side language, like PHP.

Upvotes: 2

Related Questions