gpt4 book ai didi

php - Dropzone JS 添加删除按钮

转载 作者:行者123 更新时间:2023-12-01 06:45:32 24 4
gpt4 key购买 nike

抱歉,我还是 dropzone 的新手,文件成功上传后,我需要从 Dropzone JS 创建“删除按钮”我尝试使用

if(typeof Dropzone != 'undefined')
{

Dropzone.autoDiscover = true;

$(".dropzone[action]").each(function(i, el)
{
$(el).dropzone();
});
Dropzone.createElement("<button>Remove file</button>");

}

缩略图底部仍未显示删除按钮。我的页面:

<form action="data/upload-file.php" class="dropzone"></form>

我的 PHP 上传文件

<?php

header('Content-Type: application/json');

#$errors = mt_rand(0,100)%2==0; // Random response (Demo Purpose)
$errors = false;


$resp = array(
);

# Normal Response Code
if(function_exists('http_response_code'))
http_response_code(200);

# On Error
if($errors)
{
if(function_exists('http_response_code'))
http_response_code(400);

$resp['error'] = "Couldn't upload file, reason: ~";
}

echo json_encode($resp);

最佳答案

我成功了,谢谢@pddong通过添加“addRemoveLinks: true”

if(typeof Dropzone != 'undefined')
{
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#myDropzone", {
url: "data/upload-file.php",
maxFileSize: 50,
acceptedFiles: ".pdf",
addRemoveLinks: true,
//more dropzone options here
});

}
};

页面是这样的

<form action="data/upload-file.php" class="dropzone" id="myDropzone"></form>

关于php - Dropzone JS 添加删除按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29641078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com