0
    include_once 'dbconnect.php';

    $query = "SELECT * " . "FROM download WHERE username = '" . $username . "'";

    $stmt = $conn1->prepare($query);
    $stmt->execute();
    $result = $stmt->fetchAll();
    $blob = $result[0]["File"];

    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=download.exe");
    header("Content-length: " . strlen($blob));
    echo $blob;

I have this code, when it downloads the executable is only 1 MB while the file should be 13 MB

Barmar
  • 741,623
  • 53
  • 500
  • 612
Rover1337
  • 1
  • 3
  • Set the appropriate headers and deliver the content - just like any other resource... – Honk der Hase Aug 16 '22 at 15:57
  • Ohhh... check the max packet size of the database (both client and server!). If the field content exceeds this limit, you'll need to fetch packets repeatedly until you get the entire contents of the field. On a local dev machine I would first try to increase this to see if it would fix to problem. – Honk der Hase Aug 16 '22 at 16:04
  • PhpMyAdmin is not a database, it's a web-based application for querying and managing MySQL databases. The database is MySQL. – Barmar Aug 16 '22 at 16:06
  • @HonkderHase How do you fetch a single row repeatedly? I don't think there's any API for that. You just have to increase the `max_packet_size` parameter. – Barmar Aug 16 '22 at 16:26
  • 1
    It's actually `max_allowed_packet` ...not sure if config names might vary on MariaDB. – Martin Zeitler Aug 16 '22 at 16:44
  • Does this answer your question? [How to change max\_allowed\_packet size](https://stackoverflow.com/questions/8062496/how-to-change-max-allowed-packet-size) – Martin Zeitler Aug 16 '22 at 16:45

0 Answers0