我使用Dropzone上传文件是我的代码
TABLE `payouts`
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`date_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`reciever_type` VARCHAR(25) NOT NULL,
`reciever_id` INT(10) UNSIGNED NOT NULL,
`sum` DOUBLE NOT NULL,
`description` TEXT NOT NULL,
PRIMARY KEY (`id`)
TABLE `workers`
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(40) NOT NULL
PRIMARY KEY (`id`)
TABLE `doctors`
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(40) NOT NULL,
`doctor_fields_1` TEXT ...,
`doctor_fields_2` ...
PRIMARY KEY (`id`)
上传工作正常,但我想限制上传文件的类型
<div>
<form id="mainDiv" class="dropzone needsclick" enctype="multipart/form-data" method="post" action="uploadFiles?type=5" role="form">
<div class="dz-message needsclick">
Drop files here or click to upload.<br />
<span class="note needsclick">(Please upload <strong>PDF, JPG, GIF, PNG, PDF</strong> files only.)</span>
</div>
</form>
</div>
<div>
<form id="recommendationDiv" class="dropzone needsclick" enctype="multipart/form-data" method="post" action="uploadFiles?type=5" role="form">
<div class="dz-message needsclick">
Drop files here or click to upload.<br />
<span class="note needsclick">(Please upload <strong>PDF, JPG, GIF, PNG, PDF</strong> files only.)</span>
</div>
</form>
</div>
接受的文件似乎无法正常工作,它只是对所有内容进行了升级。
答案 0 :(得分:1)
您需要包含dropzone元素的camelized ID。对于您的示例,您有<form>
id="recommendationDiv"
,因此您可以使用以下选项设置选项:
Dropzone.options.recommendationDiv = {
acceptedFiles: 'image/*'
};
您正在为不存在ID为“dropzone”的表单设置选项。使用正确的ID设置后,您应该看到正确的行为: