- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在我的系统中实现 dropzone.js 以根据文件的大小将文件上传到服务器或保管箱。
我还使用甜蜜提醒来通知。
当文件上传到我的服务器 dropzone 工作正常 但是当它上传到 dropbox 不返回任何结果
测试大于 6 Mb 的文件
而且加载栏不能正常工作
HTML:
<form id="cuadro" action="" class="dropzone">
</form>
<p id="texto_carga" style="color: #009688; display:none">Espera mientras se procesa el archivo...</p>
JS:
<script type="text/javascript">
var errors = false;
var Dropzone = new Dropzone("#cuadro", {
url: "../utilidades/pruebasupload.php?id=<?=$personaId?>&codigo=<?=$codigo?>",
acceptedFiles: ".EDF,.edf,.pdf,.PDF,.rar,.RAR,.jpg,.png,.gif",
maxFiles: 1,
error:function(){
errors = true;
},
processing:function(){
$('#texto_carga').show();
},
complete:function(){
if(errors){
swal({
title: 'Error al cargar el achivo!',
text: 'Ha ocurrido un error al intentar cargar el archivo. Póngase en contacto con el administrador del sistema',
type: 'error',
icon: 'error'
});
$('#texto_carga').hide();
}else{
swal({
title: 'Carga completa!',
text: 'Hemos cargado el archivo de la prueba exitosamente',
type: 'success',
icon: 'success'
});
$('#texto_carga').hide();
}
}
});
</script>
PHP pruebasupload.php
require_once "../terceros/dropbox/vendor/autoload.php";
require_once '../clases/servidor_archivos_controller.php';
require_once '../clases/conexion.php';
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;
use Kunnu\Dropbox\DropboxFile;
$conexion = new conexion;
$_servidor = new servidorArchivos;
$data = $_servidor->buscarConexion();
$dropboxKey = "";
$dropboxSecret = "";
$acessToken = "";
$appName= "";
$megas = "";
if(empty($data)){
$megas = 200000;
}else{
$dropboxKey = $data[0]['Keyapp'];
$dropboxSecret = $data[0]['Secret'];
$acessToken = $data[0]['Token'];
$appName= $data[0]['Appname'];
$megas = $data[0]['Megas'];
$megas = ($megas * 1024) * 1024 ;
}
if($tama[0]>$megas){
try{
//upload file to dropbox
$file = $dropbox->simpleUpload($tempFile,$nombredropbox, ['autorename' => true]);
//share a file
$response = $dropbox->postToAPI("/sharing/create_shared_link_with_settings", ["path" => $nombredropbox, "settings" => ['requested_visibility' => 'public']]);
$data = $response->getDecodedBody();
$link = $data['url'];
//save link to document in to DB
$query = "insert into pruebas_archivos (Codigo,Archivo,Ubicacion)values('$savecodge','$nombredropbox','2')";
$datos= $conexion->NonQuery($query);
http_response_code(200);
}catch(\EXCEPTION $e){
ERROR('001',$E);
http_response_code(400);
}
}else{
$targetPath = "../public/pruebas/";
$targetFile = $targetPath.$id ."_". $nombreCompleto; //5
move_uploaded_file($tempFile,$targetFile);
//save the url into DB
$query = "insert into pruebas_archivos (Codigo,Archivo,Ubicacion)values('$savecodge','$nombreCompleto','1')";
$conexion->NonQuery($query);
http_response_code(200);
}
}
function error($numero,$texto){
$ddf = fopen('error.log','a');
fwrite($ddf,"[".date("r")."] Error $numero: $texto\r\n");
fclose($ddf);
}
最佳答案
我已经测试了您的演示,有时能够上传大于 6mb 的文件。有时,在上传时,脚本恰好在 30 秒时停止。
因此,看起来你的代码逻辑没有问题,但是你的服务器发生了一些超时。正如您已经指出的那样,max_execution_time
和 max_input_time
似乎设置正确(我会用 phpinfo();
仔细检查),但取决于在您运行的服务器上,您可能还有其他地方需要检查。
httpd.conf
中的 TimeOut
指令。php-fpm
,请检查 www.conf
中的 request_terminate_timeout
指令。fastcgi_read_timeout
指令关于php - Dropzone.js 和保管箱 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56884997/
我正在使用 dropzone js,它在我需要 dropzone 的页面上运行得很好。在任何其他页面上,它都会给我一个“无效的 dropzone 元素” 错误消息并导致我的其他 javascript
我已经设置了带有可点击元素的 dropzone。单击该按钮会导致 dropzone 打开文件选择器两次,而不是一次,第二次会在选择第一个文件后立即打开。 初始化代码是: Dropzone.autoDi
我正在尝试使用Dropzone.js重新创建放置的文件/文件夹的文件夹结构。 有没有办法访问每个文件的完整路径,以便可以在php端重新创建目录结构? 最佳答案 这是一种简单的方法,您可以另外发送某些文
我有一个 DropZone除了一个异常(exception),表单工作得很好,我似乎无法根据需要精确地限制文件类型。 使用 acceptedFiles: "image/*"暗淡所有不是图像的文件夹和文
我正在尝试使用 dropzone.js FAQ 以编程方式将现有图像添加到我的 dropzone作为指南: // Add the existing image if it's there. // he
我正在使用 dropzone 来处理文件上传,并且我正在使用预览容器来指定应显示上传文件的位置。 所以我的配置如下(只剩下相关部分): var myDropzone = new Dropzone("#
我想限制 Dropzone 在您单击指定的 dropzone 区域时只选择一个文件,但我找不到任何参数来执行此操作。现在,当我选择一个文件并点击打开时,Dropzone 会立即再次弹出打开文件对话框而
我想上传一个文件并根据文件大小设置宽度和高度以适应给定的 div。例如: div size: width: 600px, height: 300px img size: width: 1200px,
我正在使用 Dropzone.autoDiscover = false 并使用 element.dropzone() 创建我的放置区。我想在另一个容器中显示处理后的文件,所以我使用了 previews
我想在我的 Web 应用程序中创建一个拖放区,用于上传图像并使用 ImageMagick 操作它们。我的拖放区始终自动上传所有图像,并在拖放区中的图像预览上显示“对象对象”错误。服务器上的上传工作正常
我已经在我的 ASP.MVC 4 上成功实现了 dropzone.js。 但我需要缩短下拉区域的高度并翻译文本。 有什么简单的方法可以做到吗?我试图修改 CSS 没有结果;下拉区域仍然采用相同的高度。
在 dropzone (或vue2dropzone),有没有办法禁用文件上传并且仅**允许通过拖放添加到dropzone。 我有一个设置,我使用自定义预览模板成功地在拖放区中设置了拖放到子区域(可单击
是否可以使用外部按钮通过 Dropzone 插件添加文件?我找到了 documentation但它没有回答我的问题。确实,我无法使用诸如单击之类的处理程序事件添加文件。有解决办法吗? 最佳答案 我猜您
当我使用 dropzone 上传多个文件时,图标显示在框外。我这张图,下图中的dropzone表格是黄色的,但是当我选择很多文件时,它们会溢出并显示在表格之外。我的 dropzone 的 CSS 是
最新的 dropzone.js 版本似乎不适用于 IE11。如何测试? 1) 打开 https://www.dropzonejs.com/examples/simple.html在 IE11 2) d
我正在尝试使用Dropzone.js在我的 Laravel 网站上。 这是我的设置: index.blade.php: @csrf 在我的 app.js 文件中,我有以下代码: window.
我正在为我的网站使用 dropzone.js 并尝试在上传之前重命名文件。最近 dropzone 添加了新函数 renameFile,我无法开始工作。这是错误还是我对功能的理解有误? console.
我正在制作一个比较应用,它有两个不同的拖放区域。每个都应该像一个单独的拖放区(用于替换或删除每个图像)。 问题: var previewaDropzone = new Dropzone("div#pr
我觉得我在这里失去了理智。我已经阅读了与我的问题相关的所有线程,我添加了“Dropzone.autoDiscover = false;”但似乎没有任何效果。 我不断得到: Uncaught Error
我在我的应用程序上使用 react-dropzone,并希望在一个页面上有多个 dropzones 来预览多个图像。例如,我希望能够将英雄图像拖放到在页面顶部显示英雄图像的拖放区。然后,我想将不同的图
我是一名优秀的程序员,十分优秀!