This commit is contained in:
Lizandro Guarnizo
2026-02-20 11:46:29 -05:00
parent 602e6d3724
commit 2f73ee2a1a
4 changed files with 273 additions and 208 deletions
+21 -5
View File
@@ -189,17 +189,33 @@ try {
if ($isLocalUrl) {
error_log("send_media_message.php - URL local detectada, subiendo archivo a WhatsApp primero");
set_time_limit(300); // Tiempo extra para archivos grandes
// Obtener la ruta local del archivo
$parsedUrl = parse_url($mediaUrl);
$relativePath = $parsedUrl['path'];
// Construir ruta absoluta
$uploadDir = __DIR__ . '/../uploads/';
$filename_from_url = basename($relativePath);
$localFilePath = $uploadDir . $filename_from_url;
// Construir ruta absoluta usando el path completo (no solo basename)
$docRoot = __DIR__ . '/..';
$localFilePath = $docRoot . $relativePath;
error_log("send_media_message.php - Ruta local del archivo: " . $localFilePath);
// Si no existe, intentar con solo el basename en uploads/
if (!file_exists($localFilePath)) {
$uploadDir = __DIR__ . '/../uploads/';
$localFilePath = $uploadDir . basename($relativePath);
}
// Último intento: buscar recursivamente en uploads/
if (!file_exists($localFilePath)) {
$searchName = basename($relativePath);
$found = glob(__DIR__ . '/../uploads/**/' . $searchName);
if (!empty($found)) {
$localFilePath = $found[0];
}
}
error_log("send_media_message.php - Ruta local del archivo: " . $localFilePath . " - existe: " . (file_exists($localFilePath) ? 'SI' : 'NO') . " - size: " . (file_exists($localFilePath) ? filesize($localFilePath) : 'N/A'));
smm_log("Local file: {$localFilePath} exists=" . (file_exists($localFilePath) ? 'yes' : 'no') . " size=" . (file_exists($localFilePath) ? filesize($localFilePath) : 'N/A'));
if (!file_exists($localFilePath)) {
throw new Exception('Archivo no encontrado en el servidor: ' . $localFilePath);