php - Dropzone范式问题
问题描述
嘿伙计们,我正在尝试以正常形式使用 dropezone,但是当我提交时似乎只对图片收费
这是我的html代码:
<form role="form" action="{{route('handleAddNewTrip')}}" class="dropzone" id="mydropzone" method="post" enctype="multipart/form-data">
{{csrf_field()}}
<div class="col-md-6">
<div class="form-group">
<label>Titre de voyage</label>
<div id="dropzonePreview"></div>
<button type="submit" name="save" class="btn btn-primary pull-right">Ajouter</button>
<button type="reset" class="btn btn-default pull-right">Annuler</button>
</div>
</div>
</form>
这是我的js代码
<script>
// Bind the event handler to the "submit" JavaScript event
$('form').submit(function(e) {
myDropzone.processQueue();
Dropzone.options.mydropzone = {
//url does not has to be written
//if we have wrote action in the form
//tag but i have mentioned here just for convenience sake
url: '{{route('handleAddNewTrip ')}}',
addRemoveLinks: true,
autoProcessQueue: false, // this is important as you dont want form to be submitted unless you have clicked the submit button
autoDiscover: false,
paramName: 'pic', // this is optional Like this one will get accessed in php by writing $_FILE['pic'] // if you dont specify it then bydefault it taked 'file' as paramName eg: $_FILE['file']
previewsContainer: '#dropzonePreview', // we specify on which div id we must show the files
clickable: false, // this tells that the dropzone will not be clickable . we have to do it because v dont want the whole form to be clickable
accept: function(file, done) {
console.log("uploaded");
done();
},
error: function(file, msg) {
alert(msg);
},
};
</script>
解决方案
可能是这样:尝试将“acceptedFiles”添加到您的 dropzone 选项中,它需要一系列接受的扩展名。它对我有用。
推荐阅读
- python - 使用 AWS 负载均衡器将来自 EKS 的 FastAPI 公开给外部世界
- kubernetes - 开始使用 KrakenD
- javascript - 在另一个类中的方法之前执行ajax调用和控制器
- asp.net - ASP.NET Cors > 只允许一个来源
- javascript - 处理使用地图函数javascript呈现的多个输入框
- python - Python - 是否有使用 GA4 admin api 创建自定义维度的特定方法?
- swift - 将 CallbackInstrument 添加到混音器时,AudioKit 混音器的最后一个通道正在翻边
- php - 如何在 for 循环中执行此操作?
- node.js - 当我在heroku上上传我的网站进行生产时,我遇到了这个问题,这个错误有什么解决方案吗?
- filebeat - 有没有办法使用 ELK 从 HTTP GET 请求中解析 HTML?