View your Apache logs after doing these mods, just in case the database has
died after your testing that worked:

It's also good to have these lines stay in there so you can debug later...

> <?php
>  mysql_connect("localhost","user","pass");

... or error_log(0, "Could not connect to database in " . __FILE__ . ":" .

>  mysql_select_db("db");

... or error_log(0, "Could not select db in " . __FILE__ . ":" . __LINE__);

>  $query = "SELECT file_path from photos where photos_id=$photos_id";
>  $result = @mysql_query($query);

... or error_log(0, "Could not exec $query in " . __FILE__ . ":" .

>  $row = mysql_fetch_row($result);
>  $path = $row[0];
>  $file_name = basename($path);
> file://print "<img src=\"$path\">";
> file://print "<div align=\"center\">$file_name</div>";
> header("Content-Type: application/download\n");

Why are you adding a \n there?  That pretty much pukes the rest of the
headers, since it's a newline you've forced in, and now the other stuff is
part of the data, not the headers...

Also, use application/octet-stream for download, I think.

> header("Content-Disposition: attachment; filename=$file_name");
> header("Content-Transfer-Encoding: binary");

Is this the full path or a relative path?  I never trust relative paths when
it comes to file-system operations.  But I have a low trust-value in
computers, software, and life in general. :-)

> readfile($path);
> ?>
> This should work shouldn't it?

If you did it right, it would work. :-)

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to