0

Hi,
Is it possible to upload a file that contains some data
and directly save the data in specific fields as in database using php?.

this is important as the data retrieved according to their field name.
Thank you.

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by Atli
0

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

0

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

my pleasure to help you:)
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 -

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

Here user_id it refers to your master table (say usermaster).
Please ask if any more clarification needed:)

0

Hey.

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.

Why do you say that?
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.

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 ;-)

Edited by Atli: Forgot one line xD

0

:) 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.

0

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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.