homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

A story of a download that didn't work

10+ Year Member

Msg#: 3038152 posted 4:23 am on Aug 8, 2006 (gmt 0)

now I'm stuck...

I'm trying to provide download from FTP space through browser link (on page saved in public_html) so that the download is done through HTTP protocol
The link passes a variable to a php doc (HTTPalt.php) that retrieves a file from FTP space

$ftpStream = ftp_connect("ftp.server.com");
$loginResult = ftp_login($ftpStream, "$WAclientLogin", "$clientPswd");
if ($loginResult) {
$files_array = ftp_nlist($ftpStream, $dirFnls);
while (list(, $this_file) = each ($files_array)) {
echo "<a href='../../_ProjectFiles/HTTPalt.php?ProjRev=$this_file'><span class='bodyTextLG'>$this_file</span></a><br>";}}

Contents of the HTTPalt.php:

header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=$ProjRev");
header("Content-Length: ".filesize("../public_ftp/$ProjRev"));

it works, except that it screws up the file it downloads...
I got a feeling that it has something to do with screwing the headers on the downloaded file... but I don't know much about it anyway so it's just a guess. It basicly downloads it (in lightning speed) - that's why I'm assuming it's not doing much at all - and when I try to open the file, it errors out saying that it's corrupted

... any thoughts on what the problem might be?



WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 3038152 posted 3:03 pm on Aug 12, 2006 (gmt 0)

I would try saving it using the top code first to be sure that portion is working correctly, if so, then it is most likely a header issue

take a look at this manual page, especially the comments, it might point you in the right direction

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved