You are here: Allowing users to download files using headers « PHP Programming Language « IT news, forums, messages
Allowing users to download files using headers

Posted by mpar612 on 12/04/06 23:15

I am trying to create an area where a user can come to a page that
queries a database and displays links to files. Here is the code for
the link:

<td><a href="download.php?path=../ftp/$path&name=$name\"
target=\"_blank\">$name</a></font></b></td>

>From what I have read the purpose of download.php is to contain the
header information to download the file. This is the only code that I
have in download.php:

<?php
$file = $_GET['file'];
$name = $_GET['name'];
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name");
?>

When I click on the original link above a window pops up with the
correct filename asking me if I want to open or save the file, but when
I save it to a disk or try opening it, I do not get the file that is on
the server. It is simply a blank file or I get an error from the
program that is trying to open the file.

What I don't understand is how does download.php know which file to
open? Am I taking the right approach to this?

Any feedback would be great. Thanks!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация