LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 07: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 07:51 AM.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:11 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration