Toggle navigation
Dashboard
Dashboard Tracker
Add / Edit My Forums
System Announcements
Discussion
Active Thread Feed
Top Threads Today
Top Threads This Week
Top Threads Library
Go!
View All
View All
Login
Logout
Home
Forums Index
Server Side
/
PHP Server Side Scripting
7:10 am Apr 28, 2026
This page requires javascript.
Forum Moderators:
coopster
Message Too Old, No Replies
upload and download a file from sql table using php
bablu
Msg#:4280766
6:19 pm on Mar 12, 2011
(gmt 0)
we want 2 upload file into database and also download it from mysql database using php..please help us..
rocknbil
Msg#:4281462
3:46 pm on Mar 14, 2011
(gmt 0)
look into mysqldump, to create the backup:
$command = "mysqldump -h $dbhost --user=$dblogin --password=$dbpass $dbname > $yourdirectory/$file";
$result = system($command);
.... will give a backup file with filename $file, be sure $yourdirectory is writable by PHP. Also be sure to read the result if it doesn't work:
if ($result) { die("could not make backup: $result"); }
To download it you open it and generate download headers, then just do readfile($file) (be sure to use full system path, NOT URL.)
Then to upload, you build a standard upload routine that ends with something like
$command = "mysql --user=$dblogin --password=$dbpass $dbname < $yourdirectory/$file";
$result = system($command);
where $file is a cleansed version of the uploaded filename. Note > and <, they should be familiar. :-)
Join The Conversation
Register
For Free! -
Become a
Pro Member
!
See forum categories
-
Enter the Forum
Moderators and Top Contributors
Moderator List
| Top Contributors:
This Week
,
This Month
,
Mar
,
Feb
,
Archive
,
Top 100 All Time
,
Top Voted Members
Hot Threads This Week
April 2026 Google Search Observations
Hello again, it's been a while
AdSense Earnings and Observations - April 2026
Do you get tired of others copying your content?
5 SEO Tips That Actually Worked for My Blog in 2026
I need some SEO help
iPhone Safari 26.4.1 errors: IPv4 & Host
2025 Link Building Trends and Insights
Does SEO matter any more?
SEO question
Home
Forums Index
Server Side
/
PHP Server Side Scripting
7:10 am Apr 28, 2026