How can I access localhost upload.php using apache2 proxy setting from my locally running AngularJS application

211 views Asked by At

I am running an AngularJS application in my local host port number 9090 which is trying to save an image. I found a quick w3 schools PHP5 Upload link to upload an image. So, Using this method I can quickly verify whether my upload image concept is working or not. When I access this without proxy, this link works fine.

When, I tried to access this link using proxy pass reverse from my AngularJS application, I am not able to access it.

I don't know anything on PHP and I just want to verify the image upload works fine or not.

My Apache2 configuration is here and it is listening on port 80

ProxyPass /upload-test http://127.0.0.1/upload-test/
ProxyPassReverse /upload-test http://127.0.0.1/upload-test/

This is my upload method from angularjs

var fd = new FormData();
//Take the first selected file
fd.append($file, $files[0]);
console.log(fd);
$http.post('/upload-test',fd, {
    headers: {'Content-Type': undefined},
    transformRequest: angular.identity
}).success(function(data,response){
    console.log("Inside Success Function ", response, data);
}).error(function(data,response){
    console.log("Inside Failure Function ", response, data);
});

Really appreciate your help

1

There are 1 answers

3
Michael On

I think thats the right location. As far as I remember all site-enabled are symbolic links to site-available.

I think your config should look like this:

ProxyPass /upload-test http://127.0.0.1:9090/upload-test/
ProxyPassReverse /upload-test http://127.0.0.1:9090/upload-test/