DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   button (Save target as) (http://www.daniweb.com/forums/thread98484.html)

Pro2000 Nov 26th, 2007 1:46 pm
button (Save target as)
 
Hi, I tried this code:

<?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/download");
        header("Content-disposition: filename=$dwnld");
        readfile($dwnld);
}
?>
I want the user to download those files from a folder named Archives... Example:
Archives/File1.zip
or Archives/File2.zip
Please I want your help quickly... Thanks.

Pro2000 Nov 26th, 2007 2:07 pm
Re: button (Save target as)
 
Maybe you did not understand.. explain? ::)
I just want to download a file by clicking on a button.. can any one help me? :? :-/

fatihpiristine Nov 26th, 2007 3:19 pm
Re: button (Save target as)
 
<a href="file1">File 1</a>
<a href="file2">File 2</a>
.....
.....
put this in for loop and it is ready

Pro2000 Nov 26th, 2007 10:50 pm
Re: button (Save target as)
 
Quote:

Originally Posted by fatihpiristine (Post 478759)
<a href="file1">File 1</a>
<a href="file2">File 2</a>
.....
.....
put this in for loop and it is ready


maybe you did not ubderstand...
I want the page download the file automatically when the variable ($id=="1") or ($id=="2")
or ($id=="3")....
can anyone tell me? Please quickly... Thanks.

fatihpiristine Nov 28th, 2007 3:31 am
Re: button (Save target as)
 
i think u dont know how to make request. it was an idea. just put there if else looop.. thats all

Pro2000 Nov 28th, 2007 9:01 am
Re: button (Save target as)
 
Quote:

Originally Posted by fatihpiristine (Post 479938)
i think u dont know how to make request. it was an idea. just put there if else looop.. thats all


Thanks but that is not correct.
I want a button locates to another page which can download a file automaticially in the header.
:-/
Thanks..

fatihpiristine Nov 28th, 2007 9:06 am
Re: button (Save target as)
 
well.. i ll try to find my code then lll post it

Pro2000 Nov 28th, 2007 11:16 am
Re: button (Save target as)
 
Thanks... Waiting for it... :)

jimmyvazquez Nov 29th, 2007 8:05 pm
Re: button (Save target as)
 
Intenta con eso a ver si te funciona.. :p
<?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");
        header("Content-Disposition: attachment; filename=".$dwnld."\n\n");
        $fp=fopen("$dwnld", "r");
      fpassthru($fp);
}
?>
I want the user to download those files from a folder named Archives... Example:
Archives/File1.zip
or Archives/File2.zip
Please I want your help quickly... Thanks.[/quote]

Pro2000 Dec 1st, 2007 1:46 am
Re: button (Save target as)
 
Quote:

Originally Posted by jimmyvazquez (Post 481139)
Intenta con eso a ver si te funciona.. :p
<?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");
        header("Content-Disposition: attachment; filename=".$dwnld."\n\n");
        $fp=fopen("$dwnld", "r");
      fpassthru($fp);
}
?>
I want the user to download those files from a folder named Archives... Example:
Archives/File1.zip
or Archives/File2.zip
Please I want your help quickly... Thanks.

[/quote]
Thanks, But what will these functions do :
$fp=fopen("$dwnld", "r");
fpassthru($fp);


All times are GMT -4. The time now is 7:43 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC