•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,165 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,335 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1655 | Replies: 18
![]() |
•
•
Join Date: Nov 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks, But what will these functions do :
$fp=fopen("$dwnld", "r");
fpassthru($fp);[/quote]
Mira, se supone que quieres bajar un archivo en estes vaso .zip, entonces este script lo debes de poner en la carpeta donde estan los archivos o concatenarle la ruta.
Ahora, lo que hace esta linea $fp=fopen("$dwnld", "r"); supongo que ya sabes, pero bueno crea un descriptor de archivo llamado fp ($fp), abre el archivo que se encuentre el nombre en $dwnld como solo lectira, lo que hace el fpassthru($fp); es leer todo lo que tenga el archivo y cuando llega al final de archivo lo cierra.. es lo que hace.. pero utiliza te pido que lo pruebes... lo que hace es bajar en este caso el archivo .zip que le pases en la variable $dwnld.
Hay otra opcion para esto pero si el usuario tiene instalos los plugins para poder abrir los archivos los visualizara en el browser, pero esto no seria automatico.. tendrias ke dar clic..
<A href="ruta/archivo" >texto</A>
no se si se pueda jamas lo he probado ya que son nuevo en php pero no se si puedas hacerlo asi..
header('location: http://127.0.0.1/archivos/'.$dwld);
fin repito no lo he calado.. pero podrias intentarlo.. espero y te ayude con eso.. :p
•
•
Join Date: Nov 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks, But what will these functions do :
$fp=fopen("$dwnld", "r");
fpassthru($fp);[/quote]
Mira, se supone que quieres bajar un archivo en estes vaso .zip, entonces este script lo debes de poner en la carpeta donde estan los archivos o concatenarle la ruta.
Ahora, lo que hace esta linea $fp=fopen("$dwnld", "r"); supongo que ya sabes, pero bueno crea un descriptor de archivo llamado fp ($fp), abre el archivo que se encuentre el nombre en $dwnld como solo lectira, lo que hace el fpassthru($fp); es leer todo lo que tenga el archivo y cuando llega al final de archivo lo cierra.. es lo que hace.. pero utiliza te pido que lo pruebes... lo que hace es bajar en este caso el archivo .zip que le pases en la variable $dwnld.
Hay otra opcion para esto pero si el usuario tiene instalos los plugins para poder abrir los archivos los visualizara en el browser, pero esto no seria automatico.. tendrias ke dar clic..
<A href="ruta/archivo" >texto</A>
no se si se pueda jamas lo he probado ya que son nuevo en php pero no se si puedas hacerlo asi..
header('location: http://127.0.0.1/archivos/'.$dwld);
fin repito no lo he calado.. pero podrias intentarlo.. espero y te ayude con eso.. :p
$fp=fopen("$dwnld", "r");
fpassthru($fp);[/quote]
Mira, se supone que quieres bajar un archivo en estes vaso .zip, entonces este script lo debes de poner en la carpeta donde estan los archivos o concatenarle la ruta.
Ahora, lo que hace esta linea $fp=fopen("$dwnld", "r"); supongo que ya sabes, pero bueno crea un descriptor de archivo llamado fp ($fp), abre el archivo que se encuentre el nombre en $dwnld como solo lectira, lo que hace el fpassthru($fp); es leer todo lo que tenga el archivo y cuando llega al final de archivo lo cierra.. es lo que hace.. pero utiliza te pido que lo pruebes... lo que hace es bajar en este caso el archivo .zip que le pases en la variable $dwnld.
Hay otra opcion para esto pero si el usuario tiene instalos los plugins para poder abrir los archivos los visualizara en el browser, pero esto no seria automatico.. tendrias ke dar clic..
<A href="ruta/archivo" >texto</A>
no se si se pueda jamas lo he probado ya que son nuevo en php pero no se si puedas hacerlo asi..
header('location: http://127.0.0.1/archivos/'.$dwld);
fin repito no lo he calado.. pero podrias intentarlo.. espero y te ayude con eso.. :p
Sorry but I do not know a lot in France, Please speak in English.Maybe you did not understand my question, Please read it again.
I want the page downloads a file automatically(The file is in a sub-folder)(Example: www.domain.com/Archive/File1.zip
Last edited by Pro2000 : Dec 1st, 2007 at 1:41 pm. Reason: Miss some words
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
•
•
•
•
Sorry but I do not know a lot in France, Please speak in English.
Maybe you did not understand my question, Please read it again.
I want the page downloads a file automatically(The file is in a sub-folder)(Example: www.domain.com/Archive/File1.zip
If you did not understand the question please say that to explain more, or to talk in private

Thanks.
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
•
•
Join Date: Nov 2007
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Yes, I yes understand, I speak Spanish not France, my English not is good, i do is put a link, on link send the name of file, and before only do
$f=$_GET["arc"];
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$f."\n\n");
$fp=fopen("$desca", "r");
fpassthru($fp);
ok ok ok.. alrady mira solo pon
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$dwnl."\n\n");
$fp=fopen("$desca", "r");
fpassthru($fp);
en el otro codigo me equivoque.. en esta parte
$fp=fopen("$desca", "r");
solo pon eso la variable $desca no tiene nada.. y solo te lo descarga.. te digo porke me funciona.. bueno sale el cuadro de dialogo.. o no quieres que salga el cuadro de dialogo..?
$f=$_GET["arc"];
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$f."\n\n");
$fp=fopen("$desca", "r");
fpassthru($fp);
ok ok ok.. alrady mira solo pon
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$dwnl."\n\n");
$fp=fopen("$desca", "r");
fpassthru($fp);
en el otro codigo me equivoque.. en esta parte
$fp=fopen("$desca", "r");
solo pon eso la variable $desca no tiene nada.. y solo te lo descarga.. te digo porke me funciona.. bueno sale el cuadro de dialogo.. o no quieres que salga el cuadro de dialogo..?
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
php Syntax (Toggle Plain Text)
<?php session_start(); $id=$_GET['fileid']; if($id=="1") { $dwnld = "File1.zip"; } else if($id=="2") { $dwnld = "File2.zip"; } else if($id=="3") { $dwnld= "File3.zip"; } if($id) { header("Content-type: application/octet-stream"); //to specify the content-type of the file. header("Content-Disposition: attachment; filename=".$dwnld."\n\n"); //to 'generate' that file save dialog box echo $dwnld; // writing the contents to that file. } ?>
I hope it helps.
Last edited by nav33n : Dec 5th, 2007 at 10:44 pm. Reason: changed [code] to [code=php] :)
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Thank you, Please read the text again,
I want to download a file from a sub folder.
Can you help me ?
I want to download a file from a sub folder.
Can you help me ?
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation:
Rep Power: 8
Solved Threads: 229
•
•
•
•
Thank you, Please read the text again,
I want to download a file from a sub folder.
Which sub folder ? You can concat the path of the sub folder like
$dwnld = "path/of/the/subfolder/here/File1.zip"; Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- "Save Target As.." isn't working in IE6 (Web Browsers)
- Save Target as... (JavaScript / DHTML / AJAX)
- Save target as... (Windows NT / 2000 / XP / 2003)
Other Threads in the PHP Forum
- Previous Thread: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
- Next Thread: sha1 md5



Linear Mode