Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //This is the download page.
- function get_path($conn, $doc_id)
- {
- $q = "Select * from docs where docID = $doc_id";
- if($res = mysqli_query($conn, $q))
- {
- while($row = mysqli_fetch_assoc($res))
- {
- return $row['path'];
- }
- }
- return false;
- }
- $doc_id = $_POST['docID'];
- $servername = "localhost";
- $username = "Bl4de";
- $password = "Bl4de-1337";
- $dbname = "web-content";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- if (!$conn)
- {
- echo "Some error occurred.";
- }
- else
- {
- $my_file = get_path($conn, $doc_id);
- header('Content-Type: application/octet-stream');
- header("Content-Transfer-Encoding: Binary");
- header("Content-disposition: attachment; filename=\"" . basename($my_file) . "\"");
- readfile($my_file);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement