我正在我的系统dropzone.js实现上传文件到服务器或dropbox,这取决于文件的大小。
我还使用甜警报作为通知。
当文件上载到我的服务器时,下拉区域正确地工作,但是当它上传到dropbox时不会返回任何结果
大于6MB的文件的测试
这里的演示
而且加载条不能正常工作。
HTML:
<form id="cuadro" action="" class="dropzone">
</form>
<p id="texto_carga" style="color: #009688; display:none">Espera mientras se procesa el archivo...</p>
联署材料:
<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 init文件


发布于 2019-07-16 09:09:05
我已经测试了你的演示,并能够上传一个大于6mb的文件,不时。有时候,在上传的时候,脚本会在30岁左右就死掉了。
因此,您的代码的逻辑似乎是正常的,但是在您的服务器中出现了一些超时。正如您已经指出的,max_execution_time和max_input_time似乎被正确设置(我会再次检查phpinfo();),但取决于您正在运行的服务器,您可能还有其他地方需要检查。
httpd.conf -- TimeOut指令。php-fpm,请签入www.conf -- request_terminate_timeout指令。fastcgi_read_timeout指令。https://stackoverflow.com/questions/56884997
复制相似问题