I am implementing in my system dropzone.js to upload files to the server or to dropbox depending on the size of the file.
And i also use sweet alerts for notifications.
When the file is uploaded to my server dropzone works correctly but when it is uploaded to dropbox does not return any results
test with files larger than 6 Mb
Demo here
and them the loading bar does not work properly
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 init file

I've tested your demo, and was able to upload a bigger than 6mb file now and then. Sometimes, while doing the upload, the script died exactly at 30s.
Thus, it seems that the logic of your code is ok, but there is some timeout occurring in your server. As you already pointed, the max_execution_time and max_input_time seems to be properly set (I'd double check with phpinfo();), but depending on the server you are running, you might have another places to check.
httpd.conf the TimeOut directive.php-fpm, check in the www.conf the request_terminate_timeout directive.fastcgi_read_timeout directivereference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With