Foros del Web » Programando para Internet » PHP »

programar opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVOS que estan en el servidor

Estas en el tema de programar opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVOS que estan en el servidor en el foro de PHP en Foros del Web. hola amigos!!!! mi problema es el siguiente, en mi pagina el administrador sube archivos al servidor en formato PDF pero el problema es a la ...
  #1 (permalink)  
Antiguo 09/07/2009, 08:49
 
Fecha de Ingreso: junio-2008
Mensajes: 50
Antigedad: 15 aos, 11 meses
Puntos: 0
programar opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVOS que estan en el servidor

hola amigos!!!! mi problema es el siguiente, en mi pagina el administrador sube archivos al servidor en formato PDF pero el problema es a la hora de que los usuarios quieren consultar esos archivos PDFS tengo que programar la opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVO.

la opcion de abrir un archivo no tengo problema, el problema es como programar la opcion donde aparece una ventana preguntando desea guardar el archivo?
  #2 (permalink)  
Antiguo 09/07/2009, 09:05
Avatar de ACX_POISON  
Fecha de Ingreso: abril-2008
Ubicacin: Talca-Chile
Mensajes: 750
Antigedad: 16 aos, 1 mes
Puntos: 7
Respuesta: programar opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVOS que estan en el ser

aqui en el foro me pasaron un codigo para eso, aun no recuerdo quien fue
el codigo es este

Cdigo PHP:
<?php
//envia como descarga un archivo determinado
$file="galeria/img/caja.png";
header("Content-Disposition: attachment; filename=" urlencode($file));   
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");            
header("Content-Length: " filesize($file));
flush(); // this doesn't really matter.

$fp fopen($file"r");
while (!
feof($fp))
{
    echo 
fread($fp65536);
    
flush(); // this is essential for large downloads

fclose($fp);
echo
"Descargando...";
?>
__________________
Me junto con los que Saben, Queriendo Saber.
  #3 (permalink)  
Antiguo 09/07/2009, 12:37
 
Fecha de Ingreso: junio-2008
Mensajes: 50
Antigedad: 15 aos, 11 meses
Puntos: 0
Respuesta: programar opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVOS que estan en el ser

muchas gracias ACX!! aplique tu codigo de la siguiente manera:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<?php
//envia como descarga un archivo determinado
$file="C:/AppServ/www/fichtec/pdf/5.pdf";
header("Content-Disposition: attachment; filename=" . urlencode($file));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($file));
flush(); // this doesn't really matter.

$fp = fopen($file, "r");
while (!feof($fp))
{
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
echo"Descargando...";
?>
</body>
</html>



ya me asegure que en el archivo 5.pdf exista en la ruta y aun a si me aparecen los siguientes errores y simbolos!!!


Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\fichtec\descargarpdf.php:9) in C:\AppServ\www\fichtec\descargarpdf.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\fichtec\descargarpdf.php:9) in C:\AppServ\www\fichtec\descargarpdf.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\fichtec\descargarpdf.php:9) in C:\AppServ\www\fichtec\descargarpdf.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\fichtec\descargarpdf.php:9) in C:\AppServ\www\fichtec\descargarpdf.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\fichtec\descargarpdf.php:9) in C:\AppServ\www\fichtec\descargarpdf.php on line 18

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\fichtec\descargarpdf.php:9) in C:\AppServ\www\fichtec\descargarpdf.php on line 19
%PDF-1.3 %쏢 8 0 obj <> stream x˶mMR6H__)k{i@-.t0%TȲ^~!?O j̸}k*9uVP=gdd232ގKo!~7? fo\*>}[;.w?])77oO[K~O~~qf'l_e]ft+m^3H_޵g~u97i?I o9_ZާoOwߤv{? efS-?/Ɨ2~:?K#՟/?b櫿/7Ȭ5uK:ڂ;2ڻ1 =ˡr|Ƹ`\uɸq)_u{f̧| #_r yfSu̪3Ĥk$%"M*j\ DnuG 2}/o7zw#?%HX>%
00000 n 0000115880 00000 n 0000216454 00000 n 0000216306 00000 n 0000116003 00000 n 0000115528 00000 n 0000000015 00000 n 0000034635 00000 n 0000372910 00000 n 0000372705 00000 n 0000410385 00000 n 0000394471 00000 n 0000394252 00000 n 0000411950 00000 n 0000116085 00000 n 0000378963 00000 n 0000378749 00000 n 0000410620 00000 n 0000348276 00000 n 0000348067 00000 n 0000409867 00000 n 0000334214 00000 n 0000334007 00000 n 0000410174 00000 n 0000216168 00000 n 0000216198 00000 n 0000216230 00000 n 0000115712 00000 n 0000034656 00000 n 0000115506 00000 n 0000216601 00000 n 0000316684 00000 n 0000325286 00000 n 0000333888 00000 n 0000333942 00000 n 0000348045 00000 n 0000372683 00000 n 0000378728 00000 n 0000394230 00000 n 0000409845 00000 n 0000411793 00000 n 0000413127 00000 n trailer << /Size 44 /Root 1 0 R /Info 2 0 R >> startxref 413480 %%EOF Descargando...


si me pudieran ayudar a corregir estos errores de los agradecere!!!
  #4 (permalink)  
Antiguo 09/07/2009, 13:07
Avatar de ACX_POISON  
Fecha de Ingreso: abril-2008
Ubicacin: Talca-Chile
Mensajes: 750
Antigedad: 16 aos, 1 mes
Puntos: 7
Respuesta: programar opcion de ABRIR ARCHIVO y DESCARGAR ARCHIVOS que estan en el ser

no debe tener etiquetas html deja solo el php
ademas basta con poner la ruta relativa al archivo(ej.: ../../doc/arrch1.pdf)
y recuerda ese codigo no lo hice yo me lo pasaron aqui en el foro,(aunque no recuerdo quien)
__________________
Me junto con los que Saben, Queriendo Saber.
Atencin: Ests leyendo un tema que no tiene actividad desde hace ms de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:24.