| | |
upload file and save the content to specific fields in mysql
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#2 26 Days Ago
You can refer this thread.It has the same discussion.
At the same time , its never advisable to store the entire file in the database.
At the same time , its never advisable to store the entire file in the database.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: May 2009
Posts: 81
Reputation:
Solved Threads: 0
0
#3 26 Days Ago
ok, thank you.
I have read it.
What I intend to upload is .doc files or pdf files.
It is not advisable to store the entire file in the database..
but does it means it is possible?
If so how?
what is the alternative you would like to suggest other than storing them in specific fields..
as all data are important for retrieval.
MAny thanks
I have read it.
What I intend to upload is .doc files or pdf files.
It is not advisable to store the entire file in the database..
but does it means it is possible?
If so how?
what is the alternative you would like to suggest other than storing them in specific fields..
as all data are important for retrieval.
MAny thanks
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#4 25 Days Ago
•
•
•
•
ok, thank you.
I have read it.
What I intend to upload is .doc files or pdf files.
It is not advisable to store the entire file in the database..
but does it means it is possible?
If so how?
what is the alternative you would like to suggest other than storing them in specific fields..
as all data are important for retrieval.
MAny thanks

You can put the entire file in the DB with TEXT as field type and but later on you may face the memory issues because of this.
The alternative is to store the files inside some folder and directory on the server (like file upload to server), and storing their file name and the path in the DB.
This table may have the structure like this -
PHP Syntax (Toggle Plain Text)
CREATE TABLE `attachments` ( `attachments_id` int(4) NOT NULL AUTO_INCREMENT, `filename` varchar(30) DEFAULT NULL, `user_id` int(4) NOT NULL, `ent_date` datetime DEFAULT NULL, PRIMARY KEY (`attachments_id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
Please ask if any more clarification needed
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
0
#5 25 Days Ago
Hey.
I wrote an article a while ago that explains how to do this in detail.
Check it out.
Why do you say that?
I can think up a few reasons why you would want to do that.
The BLOB type is better for binary data. TEXT is meant for, well, text ;-)
But yea, using BLOB for large, frequently accessed files can currently cause memory bottlenecks, because of how they are handled by MySQL. It is better suited for storing data that is not meant to be accessed every couple of milliseconds ;-)
I wrote an article a while ago that explains how to do this in detail.
Check it out.
•
•
•
•
At the same time , its never advisable to store the entire file in the database.
I can think up a few reasons why you would want to do that.
•
•
•
•
You can put the entire file in the DB with TEXT as field type and but later on you may face the memory issues because of this.
But yea, using BLOB for large, frequently accessed files can currently cause memory bottlenecks, because of how they are handled by MySQL. It is better suited for storing data that is not meant to be accessed every couple of milliseconds ;-)
Last edited by Atli; 25 Days Ago at 7:11 am. Reason: Forgot one line xD
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
And use [code] tags!
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#6 25 Days Ago
think if the website has thousands of users uploading many files to the server.So what can happen,if all this files get stored to the database directly; you will love to read this.So once you use all of the DB space, you got to buy more.and these cost more than the what is will cost to buy more disk space to store the files directly on the server.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
0
#7 25 Days Ago
That article is more than 6 years old 
The 4GB limit it talks about applies only to MyISAM tables, and only on 32bit systems with ancient MySQL setups.
This limit does not apply to the standard MySQL 5.x binaries (Unix, at least).
MyISAM tables in MySQL 5.1 have a 256TB limit, according to the manual, and InnoDB tables have double that.
And how does DB storage space cost more than HDD storage space?
They are one and the same...

The 4GB limit it talks about applies only to MyISAM tables, and only on 32bit systems with ancient MySQL setups.
This limit does not apply to the standard MySQL 5.x binaries (Unix, at least).
MyISAM tables in MySQL 5.1 have a 256TB limit, according to the manual, and InnoDB tables have double that.
And how does DB storage space cost more than HDD storage space?
They are one and the same...
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
And use [code] tags!
![]() |
Similar Threads
- Upload File (ASP.NET)
- How to save a file in database and get the content from that file(using java) (Java)
- upload file using jsp and mysql (JSP)
- File Upload To Server - Problem (ASP)
- upload file (PHP)
Other Threads in the PHP Forum
- Previous Thread: validation
- Next Thread: PHP Search Problem
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error errors execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube





