upload file and save the content to specific fields in mysql

Reply

Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

upload file and save the content to specific fields in mysql

 
0
  #1
25 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 525
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
0
  #2
25 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.
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training
 
0
  #3
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 525
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
0
  #4
24 Days Ago
Originally Posted by tulipputih View Post
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 -
  1. CREATE TABLE `attachments` (
  2. `attachments_id` int(4) NOT NULL AUTO_INCREMENT,
  3. `filename` varchar(30) DEFAULT NULL,
  4. `user_id` int(4) NOT NULL,
  5. `ent_date` datetime DEFAULT NULL,
  6. PRIMARY KEY (`attachments_id`)
  7. ) 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
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 432
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
0
  #5
24 Days Ago
Hey.

I wrote an article a while ago that explains how to do this in detail.
Check it out.

Originally Posted by network18 View Post
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.

Originally Posted by network18 View Post
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 ;-)
Last edited by Atli; 24 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!
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 525
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
0
  #6
24 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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 432
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
0
  #7
24 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...
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC