Skip to content

Instantly share code, notes, and snippets.

@efiku
Created April 4, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efiku/7bbe9923272312e890489be74ec6f88d to your computer and use it in GitHub Desktop.
Save efiku/7bbe9923272312e890489be74ec6f88d to your computer and use it in GitHub Desktop.
<?php
require "php/connect.php";
$hash = $_GET['hash'] ?? false;
if(!$hash) {
header("Location: /");
exit();
}
$pdo = new PDO(...);
$prepareOrders = $pdo->prepare("SELECT file FROM zamowienia WHERE hash=:hash");
$prepareOrders->bindParam(":hash",$hash, PDO::PARAM_STR);
$prepareOrders->execute();
$order = $prepareOrders->fetchObject();
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($order->file));
header('Expires: 0');
header('Content-Length: ' . filesize($order->file));
$fp = fopen($order->file, 'rb');
fpassthru($fp);
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment