Issues with downloading files
HI
I am quite new to all the web development stuff.
I have found these forums very useful, so now i am hoping you guys/girls may be able to help me.
I have created a document storage area within my site, the documents are stored in a database (BLOB format) and all works fine, i can upload and store documents with no problems, but the issue is around the download.
Although it works, i am having problems protecting it.
the download script works by accessing the database based on a document index, the page that contains the document list and indexes is protected, using the restrict access to page server behaviour, it calls the download script using an index variable.
but.. the download script is not protected, when i try to add the same server behaviour the download fails, IE says its trying to downlaod teh script, and that the site can not be found.
without the behaviour if someone knew the name of the php script they could just add the index variable and number and they could download any document
below is the download code, which works fine, i am assuming its because IE tries to start a second session to download the file, so the session variables that the server behaviour uses are not set...
Any suggestions
Thanks
<?php require_once('Connections/connTracker.php'); ?>
<?php
// if id is set then get the file with the id from database
if(isset($_GET['docindex']))
{$id = $_GET['docindex'];
$query = "SELECT document_name, document_type, document_size, document_content " .
"FROM tracker_documents WHERE document_index = ".$id;
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo html_entity_decode ($content);}
exit;
?>
