Programación Web y Scripting > PHP
Descargar archivo
(1/1)
neorent:
Estimado Jovenes todos:
Quisiera hacer la siguiente pregunta.
Resulta que hago una consulta y lo muestro en una tabla, pero me solicitaron que ahora esa tabla se cree en un archivo word, nada complejo, pero me pidieron algo que nunca he realizado y es guardar ese archivo en una ubicacion especifica del servidor, y me gustaria saber si alguien tiene algun link, o algun script el cual haga eso, desde ya muchas gracias a todos,
saludos,
Neo.
F_Tanori:
Prueba con esto
--- Código: PHP ---<?php @mkdir($path); $fileName=$path.'/reporte'.uniqid(ob_end_clean(); /* @header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); # Cabeceras para descargar el archivo @header("Cache-Control: private",false); @header("Content-Type: application/msword"); @header("Content-Transfer-Encoding: binary"); @header("Content-Type: application/force-download"); @header("Content-Disposition: attachment; filename="".$fileName."";" );*/ $fileContents='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Reporte en Word</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table width="20%" height="122" border="1"> <tr> <td height="71"><img src="file:///C|/images/img1.gif" width="400" height="67"></td> </tr> <tr> <td>Renglon 1 </td> </tr> <tr> <td>2</td> </tr> <tr> <td>3</td> </tr> <tr> <td>4</td> </tr> <tr> <td>5</td> </tr> <tr> <td>6</td> </tr> <tr> <td>7</td> </tr> <tr> <td>8</td> </tr> <tr> <td>9</td> </tr> </table> </body> </html>'; /* Imprimir Resultado */ fopen($fileName, 'a+'); @fclose($fileHandler); ?> debe de crearte un directorio "reportes" y dentro de el generar el archivo de word, pruebalo a ver si te sirve
El word soporta facilmente html,
Saludos
neorent:
Hola F_Tanori, muchisimas gracias quedo excelente, ahora yo lo acomodo a mis necesidades pero te quedo muy bien muchas gracias, funciona a la perfeccion,
saludos,
Neo. :D
Navegación
Ir a la versión completa