by jrptr
3 replies
Hi

I am having problems with this bit of code.


<?php

require_once( "../database.cls.php" );
require_once( "../functions.inc.php" );

userPage();
$user = $_SESSION['user'];

$db = new MySQL( DB_HOST, DB_USER, DB_PASS, DB_NAME );


$_REQUEST['file'] = str_replace('../', '', $_REQUEST['file']);

$file = 'membershipfiles/level' . $user->level . '/' . $_REQUEST['file'];

if (file_exists($file)) {

$filesize = filesize($file);

header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $_REQUEST['file']);
header('Content-length: ' . $filesize);

readfile($file);

}else {
header('Location: /members/' . $file);
}


?>


It is downloading the requested SECURE DOWNLOAD file as the original named file ( for example: test.zip ) but it only contains text inside.

The text it contains is as follows.

<br />
<b>Warning</b>: readfile() has been disabled for security reasons in <b>/home/copyknj/public_html/members/download.php</b> on line <b>24</b><br />


Any help with this problem will be greatly appreciated

Thanks
John
#code
  • Profile picture of the author Brenton
    Well i presume either your host or control panel/manager (propably cPanel) is restricting the file "download.php". Trying chmodding download.php so it has full rights.
    Signature

    Place holder.

    {{ DiscussionBoard.errors[440346].message }}
    • Profile picture of the author Bruce Hearder
      Some hosts block a whole bunch of PHP functions such as fopen, fsockopen, sometimes readfile etc..

      Can you try changing the function to file_get_contents and see if that helps.. Otherwise, it might be worth contacting your hosting company and see if they are blocking something..

      Sorry I can't suggest any quick fixes..

      take care

      Bruce
      {{ DiscussionBoard.errors[440367].message }}
      • Profile picture of the author jrptr
        Thanks Guys

        Will let you know how it works out

        Once again thanks for your help

        John
        Signature

        Get Instant Access To my Top 10 Blogging Tools & Resources dld.bz/fJH6e

        {{ DiscussionBoard.errors[440937].message }}

Trending Topics