LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Recover a file saved in a mysql table via php upload (https://www.linuxquestions.org/questions/linux-software-2/recover-a-file-saved-in-a-mysql-table-via-php-upload-463627/)

prabhatsoni 07-13-2006 07:49 AM

Recover a file saved in a mysql table via php upload
 
Hello,
From this very forum I have taken this code which saves a file in a field of a mysql table. The said file has been uploaded through "http post" and handled with php.

Code:

<?php
$uploadFile = $_FILES['form_data']['tmp_name'];
$uploadDesc = $_FILES['form_description']['form_description'];
$uploadName = $_FILES['file_data']['name'];
$uploadSize = $_FILES['file_data']['size'];
$uploadType = $_FILES['form_data']['type'];
mysql_connect("localhost","USER","PASS");
mysql_select_db("USERDATA");
$data = addslashes(fread(fopen($uploadFile, "r"), filesize($uploadFile)));
$result=MYSQL_QUERY("INSERT INTO uploads (description, data,filename,filesize,filetype) ". "VALUES ('$uploadDesc','$uploadFile','$uploadName','$uploadSize','$uploadType')");
$id= mysql_insert_id();
print "<p>File ID: <b>$id</b><br>";
print "<p>File Name: <b>$uploadName</b><br>";
print "<p>File Size: <b>$uploadSize</b><br>";
print "<p>File Type: <b>$uploadType</b><p>";
print "To upload another file <a href=http://here/minion/test2.php> Click Here</a>";
?>

Now my question is once the file has been saved in the field "data" of the table above, how can this file ever be recovered back or displayed on the web page (through apache, php, mysql). I also assume that the field "data" above is of blob type.


Any light, folks.


Prahbat Soni.


All times are GMT -5. The time now is 04:38 PM.