gpt4 book ai didi

php - Dropzone.js 和保管箱 API

转载 作者:搜寻专家 更新时间:2023-10-31 21:19:31 25 4
gpt4 key购买 nike

我在我的系统中实现 dropzone.js 以根据文件的大小将文件上传到服务器或保管箱。

我还使用甜蜜提醒来通知。

当文件上传到我的服务器 dropzone 工作正常 但是当它上传到 dropbox 不返回任何结果

测试大于 6 Mb 的文件

Demo here

而且加载栏不能正常工作

Dropzone.js

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);
}

PHP 初始化文件 enter image description here enter image description here

最佳答案

我已经测试了您的演示,有时能够上传大于 6mb 的文件。有时,在上传时,脚本恰好在 30 秒时停止。

因此,看起来你的代码逻辑没有问题,但是你的服务器发生了一些超时。正如您已经指出的那样,max_execution_timemax_input_time 似乎设置正确(我会用 phpinfo(); 仔细检查),但取决于在您运行的服务器上,您可能还有其他地方需要检查。

  • 如果它在 Apache 上运行,请检查 httpd.conf 中的 TimeOut 指令。
  • 如果您使用的是 php-fpm,请检查 www.conf 中的 request_terminate_timeout 指令。
  • 如果您使用的是 nginx,请检查 fastcgi_read_timeout 指令

reference

关于php - Dropzone.js 和保管箱 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56884997/

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