Skip to content

Instantly share code, notes, and snippets.

@joelmiguelvalente
Last active May 9, 2022 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelmiguelvalente/3d1af9c2bff76ef24b41b02ffe163f2f to your computer and use it in GitHub Desktop.
Save joelmiguelvalente/3d1af9c2bff76ef24b41b02ffe163f2f to your computer and use it in GitHub Desktop.
[MOD] BBCode file para archivos
<?php
/**
* Download
* -------------------------------------------------------------
* File: download.php
* Name: download
* Purpose: Control de descarga de archivos
* @link: https://phpost.net/foro/
* @author: Miguel92
* @version: 1.0
* -------------------------------------------------------------
*/
# CONTINUAR EL SCRIPT
$tsContinue = true;
include "../../header.php";
$tsTitle = "{$tsCore->settings['titulo']} - Descargando...";
if($tsContinue) {
$dato = db_exec('fetch_assoc', db_exec([__FILE__, __LINE__], 'query', "SELECT * FROM a_files WHERE file_id = {$_GET["id"]}"));
/**
* En donde tengan los archivos subidos https://tuweb.com/files/archivo./zip/rar/png/etc.
*/
$archivo = TS_ROOT . "files/{$dato["file_id"]}.{$dato["f_ext"]}";
/**
* El nuevo nombre que tendrá {tituloweb}_{archivo}.{extension}
*/
$nombre = "{$tsCore->settings["titulo"]}_{$dato["file_id"]}.{$dato["f_ext"]}";
if(file_exists($archivo) && is_readable($archivo)) {
// encabezados, y sin caché
header('Content-type: application/octet-stream');
header('Content-disposition: attachment; filename=' . $nombre);
header('Content-transfer-encoding: binary');
} else die("0: El archivo no existe.");
exit();
} else die("0: El archivo no existe.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment