Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-13-2006, 07:49 AM   #1
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Rep: Reputation: 30
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')");
$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.

Last edited by prabhatsoni; 07-13-2006 at 07:51 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
upload of image in database (php+mysql) Pravab Programming 5 11-08-2006 11:05 AM
php file upload lord-fu Programming 2 04-29-2006 11:03 PM
PHP/MySQL table question newuser455 Programming 10 11-03-2005 04:50 AM
Where Do I Upload PHP, Perl, MySQL, etc..? John_Saunders Linux - Software 4 06-08-2002 04:24 PM
File upload via PHP saravanan1979 Programming 1 02-14-2002 04:28 AM

All times are GMT -5. The time now is 10:55 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration