我正在尝试使用Dropzonejs上传音乐和视频文件,当我尝试使用图像文件时,它工作得很好,上传是成功的,如果用视频和音乐文件来尝试,就会产生这样的错误:
警告帖内容-字节超过
我已经设置了下拉区域的配置,但是它似乎不能解决这个问题。因为我正在使用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.发布于 2016-10-26 12:08:50
谢谢各位。简单的错误是我没有重新启动Laravel服务器。很感谢你。
https://stackoverflow.com/questions/40260137
复制相似问题