【问题标题】:Uploading larger file size using Dropzonejs使用 Dropzonejs 上传更大的文件
【发布时间】:2016-10-26 10:42:53
【问题描述】:

我正在尝试使用 Dropzonejs 上传音乐和视频文件,当我尝试使用图像文件时它工作正常,上传成功,尝试使用视频和音乐文件时出现此错误:

警告帖子内容的--------字节超出了--------的限制

我已经设置了 dropzone 的配置,但似乎没有解决这个问题。因为我用的是Laravel,所以我编辑了xampp的php_ini文件,增加了max_file_size等一些参数,也没有解决问题。

由于我运行的是 Laravel-5.3,很明显它可能有自己的内部服务器,因为无论我是否在运行 Xampp,一旦我启动 Laravel 服务器,无论是否在 Xampp 上启动 apache,它都会运行。我该怎么办?

    <div class="row">
            <div class="col-md-12">
                <form action="{{ url('/songs/do-upload') }}" class="dropzone" id="addSongs">{{csrf_field()}}
                <input type="hidden" name="albums_id" value=" {{$albums->id}} ">
                </form>
            </div>
        </div>

<script type="text/javascript">
        Dropzone.options.addSongs = { 
              paramName: 'file',
              clickable: true,
              enqueueForUpload: true,
              autoProcessQueue: true,
              uploadMultiple: true,
              parallelUploads: 5,
              maxFiles: 1,
              maxFilesize: 250,
              addRemoveLinks: true,
              dictDefaultMessage: 'Drag your images here',
              init: function() {
                   console.log('init');
                   this.on("maxfilesexceeded", function(file){
                        alert("No more files please!");
                        this.removeFile(file);
                    });

            }
        };
    </script>

上传时使用的控制器:

public function doImageUpload(Request $request){

        $file = $request->file('file');
        $fileName = uniqid() .$file->getClientOriginalName();
        $file->move('album/songs', $fileName);

        $albums = Albums::findOrFail($request->input('albums_id'));

        $album = $albums->songs()->create([
            'user_id' => Auth::user()->id,
            'albums_id' => $request->input('albums_id'),
            'file_name' => $fileName,
            'file_size' => $file->getClientSize(),
            'file_mime' => $file->getClientMimeType(),
            'file_path' => 'album/songs' .$fileName
        ]);

    }

控制台上的错误信息:

1:107 Uncaught ReferenceError: Dropzone is not defined
http://localhost:8000/songs/do-upload Failed to load resource: the server responded with a status of 500 (Internal Server Error)
jquery-1.9.0.js:1'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead.

【问题讨论】:

    标签: laravel-5 file-upload laravel-blade dropzone.js large-files


    【解决方案1】:

    谢谢大家。一个简单的错误是我没有重新启动 Laravel 服务器。欣赏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      相关资源
      最近更新 更多