I have a script that i use for my downloadable files.
Bu when i try to download a file with IE it suggests a different
filename
than what i wrote in the code.
For example. If i try to download the file 'download.test. zip' it
suggests
'download[1].test.zip' instead.
I i use Mozilla Firefox to download the file it works fine...
And another question: what does the @-character before
require('includ es/sys.dbconnect.p hp') really do? :)
I think i read it somewhere but i cant seem to remember what it
means...
Thanks
code:
-------------------------------------------------------------------------
<?php
if(IsSet($_GET['id']))
{
$fileid = $_GET['id'];
$query = "SELECT sFilename FROM tblFiles WHERE fileId=" . $fileid .
";";
$updatequery = "UPDATE tblFiles SET iHits=(iHits + 1) WHERE
fileId=" . $fileid . ";";
if(@require('in cludes/sys.dbconnect.p hp'))
{
if($result = mysql_query($qu ery))
{
if($rad = mysql_fetch_arr ay($result))
{
if(mysql_query( $updatequery))
{
header('Content-type: application/x-download');
header('Content-Disposition: attachment; filename="' .
$rad[0] . '"');
header("Content-Length: " . filesize("../files/" .
$rad[0]));
readfile("../files/" . $rad[0]);
}
}
else
{
echo "The file does not exist.";
}
}
else
{
echo "SQL Error.";
}
}
}
else
{
header('Locatio n: http://www.google.com' );
}
exit();
?>
Bu when i try to download a file with IE it suggests a different
filename
than what i wrote in the code.
For example. If i try to download the file 'download.test. zip' it
suggests
'download[1].test.zip' instead.
I i use Mozilla Firefox to download the file it works fine...
And another question: what does the @-character before
require('includ es/sys.dbconnect.p hp') really do? :)
I think i read it somewhere but i cant seem to remember what it
means...
Thanks
code:
-------------------------------------------------------------------------
<?php
if(IsSet($_GET['id']))
{
$fileid = $_GET['id'];
$query = "SELECT sFilename FROM tblFiles WHERE fileId=" . $fileid .
";";
$updatequery = "UPDATE tblFiles SET iHits=(iHits + 1) WHERE
fileId=" . $fileid . ";";
if(@require('in cludes/sys.dbconnect.p hp'))
{
if($result = mysql_query($qu ery))
{
if($rad = mysql_fetch_arr ay($result))
{
if(mysql_query( $updatequery))
{
header('Content-type: application/x-download');
header('Content-Disposition: attachment; filename="' .
$rad[0] . '"');
header("Content-Length: " . filesize("../files/" .
$rad[0]));
readfile("../files/" . $rad[0]);
}
}
else
{
echo "The file does not exist.";
}
}
else
{
echo "SQL Error.";
}
}
}
else
{
header('Locatio n: http://www.google.com' );
}
exit();
?>
Comment