problems with donwload
- From: ross@xxxxxxxxxxxxxx ("Hulf")
- Date: Thu, 27 Sep 2007 11:10:26 +0100
Under the results there are 3 files to download. Some users are getting an
uable to read or corrupt message.
http://vps.aztechost.co.uk/~trisco/index.php
and 3 here
http://vps.aztechost.co.uk/~trisco/rankings.php
The upload script is similar
if(isset($_POST['_upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$id= $_POST['id'];
/*$query = "UPDATE results SET title='$title', file_name='$fileName',
size='$fileSize', type='$fileType', content='$content',
last_updated=CURDATE() WHERE id=$id";*/
$query ="INSERT INTO results (title, content, file_name, size, type,
last_updated) VALUES ('$title', '$content', '$fileName', '$fileSize',
'$fileType', CURDATE())";
mysql_query($query);
echo mysql_error();
}
and the download....
<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database
include("/home/trisco/public_html/secure/scripts/connect.php");
$id = $_GET['id'];
$query = "SELECT file_name, type, size, content FROM results WHERE id =
'$id'";
$result = mysql_query($query) or die(mysql_error());;
list($file_name, $type, $size, $content) =
mysql_fetch_array($result);
/*echo $file_name;
echo $type;
echo $size;*/
header("Content-Type: $type");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Length: ".filesize($file));
header("Accept-Ranges: bytes");
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-transfer-encoding: binary");
echo $content;
exit;
}
?>
I can open them on my desktop and laptop. Any clue why this is happening?
Permissions?
Thanks,
R.
.
- Follow-Ups:
- Re: [PHP] problems with donwload
- From: Jim Lucas
- Re: [PHP] problems with donwload
- Prev by Date: freopen?
- Next by Date: languages and PHP
- Previous by thread: freopen?
- Next by thread: Re: [PHP] problems with donwload
- Index(es):
Relevant Pages
|