Steponas Kazakevicius has written up a new tutorial about file uploading and, more specifically, making an upload tool that can handle interruptions. Have you ever been to a website that offers downloads of stuff? And while you are waiting for the download, there are lots of ads around? Sure you have. I have too. The last day I was downloading stuf …
Tag Archives: download
Hacer drag & drop de ficheros fuera del navegador con Chrome
Hace tiempo comenté cómo hacer drag & drop directamente sobre el navegador, lo cual nos venía muy bien para subir ficheros (por ejemplo para un correo, galería de fotos, …). Esta vez se trata de descargar ficheros directamente desde el navegador, algo que permite GMail desde Chrome.
El autor de este post lo ha tenido difícil para poder ver cómo lo hace Google, pero al final el código es bastante sencillo:
var file = document.getElementById("dragout");
file.addEventListener("dragstart",function(evt){
evt.dataTransfer.setData("DownloadURL",fileDetails);
},false);
Sólo disponible en Chrome
Descargas seguras mediante PHP
Interesante script que te ayudará si no quieres que la gente acceda directamente a tus ficheros para bajárselos. Para ello lo que hará será recoger un parámetro con el fichero que se quiere bajar, añadirle el path donde se encuentra y mediante la cabecera de la respuesta (header) devolver el fichero.
<?
$dir="/path/directorio/";
if (isset($_REQUEST["fichero"])) {
$fichero=$dir.$_REQUEST["fichero"];
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($fichero));
header("Content-disposition: attachment; filename=\"".basename($fichero)."\"");
readfile("$fichero");
} else {
echo "Fichero seleccionado";
}
?>
Si avanzáis en el artÃculo, veréis un caso más práctico con la base de datos.
VÃa / Good PHP Tutorials