Anglejs – 跨域图像上传角度laravel

我一直在服务器上的图像上传困难.我正在使用 ngFileUpload在前端.但我总是得到

“对预检要求的响应不通过访问控制检查:请求资源上不存在”Access-Control-Allow-Origin“头”

文件上传角色代码

var uploadFile = function (file) {
      if (file) {

            if (!file.$error) {
              Upload.upload({
                  url: baseUrl+'upload',file: file


              }).progress(function (evt) {
                  var progresspercentage = parseInt(100.0 * evt.loaded / evt.total);
                  //console.log(evt.total);
              }).success(function (data,status,headers,config) {
                  $timeout(function() {

                    console.log(data);
                    console.log(status);
                      if(status==200)
                        {

                          logo_path = data.logo_path;

                        }

                  });
              });
            }

      }
  };

在Laravel我已经配置了这样的CORS:

public function handle($request,Closure $next)
{
    header("Access-Control-Allow-Origin: http://localhost:8001/");

    // ALLOW OPTIONS METHOD
    $headers = [
        'Access-Control-Allow-Methods'=> 'POST,GET,OPTIONS,PUT,DELETE','Access-Control-Allow-Headers'=> 'Content-Type,X-Auth-Token,Origin'
    ];
    if($request->getmethod() == "OPTIONS") {
        // The client-side application can set only headers allowed in Access-Control-Allow-Headers
        return Response::make('OK',200,$headers);
    }

    $response = $next($request);
    foreach($headers as $key => $value)
        $response->header($key,$value);
    return $response;
}

正常跨域POST请求工作正常.即$http.post().我已经尝试了许多不同的标题变体,但没有帮助.此外,OPTIONS请求返回200 OK,但仍显示预检反应失败消息.任何人都可以帮助我如何进一步调试这个问题?

尝试添加
header('Access-Control-Allow-Origin: *'); 
header('Access-Control-Allow-Headers: Origin,Content-Type'); 
header('Access-Control-Allow-Methods: POST,DELETE');

在bootstrap / app.PHP您也可以在此处插入您可能需要访问控制的任何其他标题.

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...