LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

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

Rep: Reputation: 30
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.

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


Reply


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 12:05 PM
php file upload lord-fu Programming 2 04-30-2006 12:03 AM
PHP/MySQL table question newuser455 Programming 10 11-03-2005 05:50 AM
Where Do I Upload PHP, Perl, MySQL, etc..? John_Saunders Linux - Software 4 06-08-2002 05:24 PM
File upload via PHP saravanan1979 Programming 1 02-14-2002 05:28 AM


All times are GMT -5. The time now is 09:17 AM.

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