php does not detect subfolders and files
one text
Solution:
Try to change
$nombre_fichero = 'documentos/$subdirectory[$i]/".$doct[1].';
to
$nombre_fichero = 'documentos/' . $subdirectory[$i] . '/' . $doct[1].';
Also, try to avoid using other languages in variable "names".
Source