ChompGator Posted January 7, 2009 Share Posted January 7, 2009 Hello, I recently developed a PHP script that allows users to upload files into a MySQL database. My next step is having a PHP page that shows the files by ID | File Name And the File Name should be linked to the file so when a user clicks on the file name, it starts downloading the file.... Ive tried doing it a few different ways, but none of my methods seem to work...I was wondering if anyone had any advice (my script is below, and the script that inserts the file into the db) This script does not link the file name to the file, I couldn't seem to get that part to work! Thanks Display.php <?php // Connects to your Database mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error()); $data = mysql_query("SELECT * FROM uploads") or die(mysql_error()); Print "<table border cellpadding=3>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<th>ID:</th> <td>".$info['id'] . "</td> "; Print "<th>File Name:</th> <td>".$info['filename'] . " </td></tr>"; } Print "</table>"; ?> Insert-Into-Db.php <?php mysql_connect("","",""); mysql_select_db(""); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO uploads (description, data,filename,filesize,filetype) ". "VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')"); $id= mysql_insert_id(); print "<p>File ID: <b>$id</b><br>"; print "<p>File Name: <b>$form_data_name</b><br>"; print "<p>File Size: <b>$form_data_size</b><br>"; print "<p>File Type: <b>$form_data_type</b><p>"; print "To upload another file"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.