Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Query in downloading from server

  Asked By: Nichole    Date: Jun 11    Category: Java    Views: 772
  

Actually I have to download some backedup file
from a server to local machine when the form is being submitted.I
have no idea about it.The code can be in any Web Technologies
(JSP,Servlet,Cold Fusion).

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Gorkem Yilmaz     Answered On: Jun 11

> from a server  to local  machine when the form  is being submitted.I
> have no idea  about it.The code  can be in any web  Technologies
> (JSP,Servlet,Cold Fusion).If u have any idea send me in reply.

<?php

if (isset($_POST['filename']) )
{
$downloadfile=$_POST['filename'];

include($downloadfile);

}
else {
include('reject.php');
}

?>

that is one way, however include will display the file, probably not what you
want. this is probbaly better:

<?php
header("Content-Disposition: attachment; filename=" . $downloadfile);
$datafile = fopen("$downloadfile","r");
$data = fread($datafile, 1000000);
echo $data;
?>

You will of course have to add a loop os that $data become $data = $data + more
read data.

 
Didn't find what you were looking for? Find more on Query in downloading from server Or get search suggestion and latest updates.




Tagged: