Función PHP para forzar la descarga de archivos

function force_download($file)
{
	if ((isset($file))&&(file_exists($file)))
	{
	        header("Content-length: ".filesize($file));
		header('Content-Type: application/octet-stream');
		header('Content-Disposition: attachment; filename="' . $file . '"');
		readfile("$file");
	}
	else
	{
		echo "No se ha seleccionado ningún fichero";
	}
 }
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay


Tags: ,
Esta entrada fue posteada el Friday, September 11th, 2009 a las9:53 AM bajo la categoria php. Tu puedes seguir los comentarios a este post a travez de RSS 2.0 feed. Vos podes dejar un comentario, o trackback desde tu propio sitio.

Dejar un comentario

Tu comentario