Dropzone图片上传选项不起作用:( [英] Dropzone image upload options not working :(
问题描述
我正在尝试构建一个拖放图片上传,但dropzone选项不起作用,我不知道我是否正确的方式。
Im trying to build a drag and drop image upload but dropzone options dont work and I dont know if im doing it the right way.
我很乐意设置以下选项:
I would love to set up the following options:
-
仅上传一个文件(multiupload参数)
Upload only one file (multiupload parameter)
删除该文件的可能性(addremovelink?)
Possibility to remove that file (addremovelink?)
最大文件大小为2mb(maxfilesize)
Max file size of 2mb (maxfilesize)
你能帮我吗?
这里是代码:
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="dropzone.js" type="text/javascript"></script>
<link href="css/basic.css" rel="stylesheet" type="text/css" />
<link href="css/dropzone.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$("#uploadme").dropzone({
paramName: 'photos',
url: 'upload.php',
dictDefaultMessage: "Drag your images",
clickable: true,
enqueueForUpload: true,
maxFilesize: 1,
uploadMultiple: false,
addRemoveLinks: true
});
});
</script>
<form action="upload.php" class="dropzone">
<div id="uploadme" class="fallback">
<input name="file" type="file" multiple />
</div>
</form>
</body>
</html>
谢谢你们,你摇滚! :)
Thank you guys, you rock! :)
推荐答案
在Jquery调用之前添加
Just add before Jquery call
Dropzone.autoDiscover = false;
并从< form> $ c $中删除操作C>。
这将禁用自动发现功能,因此您可以为表单指定所有选项。
and remove the action from the <form>
.
That will disable the auto discover function so you can specify all the options for your form.
这是您的代码应该是这样的:
This is what your code should look like:
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="dropzone.js" type="text/javascript"></script>
<link href="css/basic.css" rel="stylesheet" type="text/css" />
<link href="css/dropzone.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
Dropzone.autoDiscover = false;
$("#uploadme").dropzone({
paramName: 'photos',
url: 'upload.php',
dictDefaultMessage: "Drag your images",
clickable: true,
enqueueForUpload: true,
maxFilesize: 1,
uploadMultiple: false,
addRemoveLinks: true
});
});
</script>
<form action="" class="dropzone">
<div id="uploadme" class="fallback">
<input name="file" type="file" multiple />
</div>
</form>
</body>
</html>
这篇关于Dropzone图片上传选项不起作用:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!