Created
April 4, 2016 14:45
-
-
Save efiku/7bbe9923272312e890489be74ec6f88d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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