Need Help With Code

by 3 replies
4
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
#programming #code
  • 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.
    • [ 1 ] Thanks
    • [1] reply
    • 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
      • [ 1 ] Thanks
      • [1] reply

Next Topics on Trending Feed