0

我正在尝试使用此链接https://github.com/danialfarid/ng-file-upload在 angularjs 中的 WAMP(localhost) 上上传文件。但是当我在 localhost 上上传文件时,我收到一个包含该文件夹的 HTML 代码的 html 响应(在日志中)。

$scope.$watch('file', function (file) {
          console.log("uploading file");
          $scope.upload($scope.file);
        });
         $scope.log = '';
/* optional: set default directive values */
//Upload.setDefaults( {ngf-keep:false ngf-accept:'image/*', ...} );

$scope.upload = function (file) {
    console.log("in upload function");

            Upload.upload({
                url: 'http://localhost/dominodonationform/fileuploads',
            headers: {'Content-Type': undefined },
            transformRequest: angular.identity,
                file: file
            }).progress(function (evt) {
                console.log("In progress");
                var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
                $scope.log = 'progress: ' + progressPercentage + '% '+ evt.config.file.name;                               
            }).success(function (data, status, headers, config) {
                console.log("success");
                $timeout(function() {
                    $scope.log = 'file: ' + config.file.name + 'Uploaded , Response: ' + data + '\n' + $scope.log;
                });
            }).error(function (data, status, headers, config) {
                    console.log('error status: ' + status);
                });


};

请帮我..

我在日志中得到的响应是

             Upload Log:
        file: abcd.txtUploaded , Response: <!DOCTYPE HTML PUBLIC "-                     `enter code here`//W3C//DTD HTML 3.2 Final//EN">
            <html>
           <head>
           <title>Index of /dominodonationform/fileuploads</title>
            </head>
            <body>
             <h1>Index of /dominodonationform/fileuploads</h1>
             <table>
                 <tr><th valign="top"><img src="/icons/blank.gif" alt="             [ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last  modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
       <tr><th colspan="5"><hr></th></tr>
          <tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]">                      </td><td><a href="/dominodonationform/">Parent Directory</a></td><td>&nbsp;</td>  <td align="right">  - </td><td>&nbsp;</td></tr>
        <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td>  <td><a href="New%20folder/">New folder/</a>            </td><td align="right">2015-08-10 10:03  </td><td align="right">  - </td><td>&nbsp;</td></tr>
 <tr><th colspan="5"><hr></th></tr>
 </table>
  <address>Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port    80</address>
     </body></html>

     progress: 100% abcd.txt

请帮我。成功后,我将用原始 URL 替换该 URL。

4

0 回答 0