FusionBB
Sponsored by Dreamers Empire - Helping entrepeneurs build their dreams.
Dreamers Empire
Username Post: php Help
Nikos
FusionBB Addict
Total Posts: 846
*
Birthday: 04-22 
Location: Thessaloniki, Hellas
Average Post Ranks%:                       
06-02-06 09:52 AM - Post#34200    
    In response to greg

Ok here is the deal.

For starters the php.ini file has to have output buffering set to anything other than off. If that is not the case the code will not work and you will see various weird results regarding what you need to do.

I would suggest you create a page which will receive a file id (via get) and using that it will connect to the database and increase the file download counter by one (what you need really).

Following that you can have the following code to use the Save As button:

Code:

<?php

$_FileID = retrieveData('g','fid');
$_Action = retrieveData('g','action');

if (!is_numeric($_FileID))
{
dieHere(true,'No File ID passed');
}

if ($_Action == 'download')
{
// Connect to the database and update Counters
$sql = "UPDATE xxx SET field = field + 1 WHERE file_id = '$_FileID'";
// Execute the query here etc.
// ----------------

// Get the file name
$sql = "SELECT filename FROM xxxx WHERE file_id = '$_FileID'";
// Execute the query here etc.
// ----------------
list($_FileName) = ....

// Download the file for the user
$_Extension = strtolower(substr(strrchr($_FileName, '.'), 1));


header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename='. basename($_FileName) . ';' );
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. @filesize($_FileName));

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>File Downloader</title>
</head>
<body>
Some links will go here to call the same php document with a get variable regarding the action (action/download)
</body>
</html>


Contact Me

NOTE: You are viewing an individual Post. View the Entire Topic
FusionBB™ Version 3.2 | ©2003-2013 InteractivePHP, Inc.
Execution time: 0.074 seconds.   Total Queries: 42   Zlib Compression is on.
All times are (GMT-4). Current time is 09:14 AM
Top