||07-13-2006 08:49 AM
Recover a file saved in a mysql table via php upload
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.
$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'];
$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')");
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.