Jump to content

dan09

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dan09's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I will try it out and see what happens. Thanks for quick reply
  2. I would like it to list a bunch of music in a folder but the user dosent have accesses to except me. So the page he can view will list all the files in the other folder and has a downloadable link to it so he can download the files Thanks Dan
  3. Thanks mate i got it working in the end. Great help and advice Thanks
  4. It is still not working All i get is a blank screen
  5. The file is currently located at: test/download.php I would to download a file stored at : test/files/music.mp3
  6. Ok so how should my database look like? 1) /files/file.zip 2) domain.com/files/file.zip
  7. Sorry i meant to put :domain.com/download.php?id=1 On the database i have changed where the file is stored. But still not working Im not sure whey its not working Here is my script: <?php // Make a MySQL Connection mysql_connect("localhost", "username", "Password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // Retrieve all the data from the "example" table $id = (int)$_GET['id']; $result = mysql_query("SELECT * FROM download where id = $id") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry $file = $row['file_location']; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="file.zip"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); ob_clean(); flush(); exit; }
  8. A) the url is correct i have tested it out B) i forgot to delete echo of file and id. Now nothing is displayed and no download stating. C) still not fixed
  9. Ok it kind of works i browers: domain.com/download.php?=id1 The output is just text displaying the id and the location of the file I would like it to start downloading not display the location of the file
  10. Any ideas into what the next set is?
  11. Ok i have added all the script into the file and it looks like this: <?php // Make a MySQL Connection mysql_connect("localhost", "username", "Password") or die(mysql_error()); mysql_select_db("databasr") or die(mysql_error()); // Retrieve all the data from the "example" table $id = (int)$_GET['id']; $result = mysql_query("SELECT * FROM download where id = $id") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry echo "Id: ".$row['id']; echo " File: ".$row['file_location']; $file = $row['file_location']; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } ?> When i load the script (download.php) All that is displayed is: Id: File: No data
  12. Could you show me where abouts this would go in the script? Sorry im new to php and phpmyadmin
  13. <?php // Make a MySQL Connection mysql_connect("localhost", "username", "Password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM download") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry echo "Id: ".$row['id']; echo " File: ".$row['file_location']; ?> Ok i have this to query my database it works Could you suggest any other moddifications where needed please? The next thing is to use that example you suggested to me. Im not sure how i would use it. Could you help me with this please?
  14. Ok i have made the database how would i go about creating a file to query the database?
  15. On some website (not sure which ones) they have a id for each file to download E.G: http://domain.com/download.php?id=30 I would like to create somthing like this but not sure how. I think this will need a database aswell to work Could you help me out? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.