hi i am new to php. i am getting the following error
----Warning: fopen(C:/Program Files/Apache Group/Apache2/htdocs/Project/) [function.fopen]: failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\Project\download.php on line 4----
----Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\Apache Group\Apache2\htdocs\Project\download.php on line 27------

<?php
$path = $_SERVER['DOCUMENT_ROOT']."/Project/"; 
$fullPath = $path.$_GET['filename'];
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"); 
            header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); 
        break;
        default;
            header("Content-type: application/octet-stream");
            header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
        }
        header("Content-length: $fsize");
        header("Cache-control: private"); 
    while(!feof($fd)) 
    {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;

?>

>> failed to open stream: No such file or directory

It's trying to open "C:/Program Files/Apache Group/Apache2/htdocs/Project/" which isn't a file as you can see and that's why it failed. This means that $_GET['filename'] doesn't contain a value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.