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

Recommended Answers

All 2 Replies

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

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');
}
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.