Hi, I've searched the forum for this error that I'm having, and unfortunately other posts are in different languages.
The error that I'm having is this:
Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/usr/local/apache/htdocs../files/Assignment_No1.pdf) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a5970550/public_html/admin/downloadFile.php on line 7
Warning: fopen(/usr/local/apache/htdocs../files/Assignment_No1.pdf) [function.fopen]: failed to open stream: Operation not permitted in /home/a5970550/public_html/admin/downloadFile.php on line 7
Warning: fclose(): supplied argument is not a valid stream resource in /home/a5970550/public_html/admin/downloadFile.php on line 38
This is the PHP file where the error is coming from:
Quote:
<?php
$path = $_SERVER['DOCUMENT_ROOT']."../files/"; // change the path to fit your websites document structure
$fullPath = $path.$_GET['file'];
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf"); // add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
break;
case "doc":
header("Content-type: application/msword"); // add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
break;
case "jpg":
header("Content-type: application/jpeg"); // add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
?>
|
What I'm try to do here is to download a file that has been stored to a certain folder in the server wherein the filename is stored in the database.
What can I do to fix this error?
Similar error is being shown whenever I upload and unlink an image..
Warning: unlink() [function.unlink]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/registeredUser/userPhoto/Linkin_Park_033.jpg) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a5970550/public_html/registeredUser/viewNominee.php on line 20
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/registeredUser/userPhoto/9X-Shiny-Silver-425x425.jpg) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a5970550/public_html/registeredUser/viewNominee.php on line 33
Please help.. Thanks