0

Opening a image file gives an empty file. A .txt file can be opened.
Opening the image file gives no view available.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by tkal
0

what type of file and what is the script you use to pull it up

I am trying to open a .jpg file, writing in php.

$file = str_replace(" ", "_", $_GET["filename"]);
$local_file = UPLOAD_FOLDER.$file;
$download_file = $_GET["filename"];

$download_rate = 40;
$_SESSION['ext']= "";
if(file_exists($local_file) && is_file($local_file)){
    header('Cache-control: private');
    header('Content-Type: application/octet-stream');
    header('Content-Length: '.filesize($local_file));
    header('Content-Disposition: attachment; filename="'.$file.'"');

    flush();
    $file = fopen($local_file, "rb");
    while (!feof($file)){
        print fread($file, round($download_rate * 1024));
        flush();
        ob_flush();
        sleep(1);
    }
    fclose($file);
    exit;
}
else{
  die('Error: The file '.$local_file.' does not exist');
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.