Not really.
A textfile is nothing more than a really long string.
So you put it into the database asif it was a really long string.
But, a textfile is bound to contain quotes, newlines etc.
If you just copied the file into the SQL query, the query wouldn't be valid anymore.
For ex, if you string was:
Hello, I am a "textfile" with some "quotes" in it
then the query would look like:
INSERT INTO table SET field="Hello, I am a "textfile" with some "quotes" in it";
As you can imagine, this string contains way too many quotes:
"Hello, I am a "textfile" with some "quotes" in it";
If you break it into quoted strings, you'd get
"Hello, I am a "
textfile
" with some "
quotes
" in it";
SQL will interpret 'textfile' and 'quotes' as SQL commands instead of data.
So you need to get rid of the quotes by escaping them, using the 'addslashes()'
function.
Then it will look like:
INSERT INTO table SET field="Hello, I am a \"textfile\" with some \"quotes\" in it";
Now SQL will read the \" as the quote character, and not a quote that means 'end of string'
Note: escaping is done with a backslash in MySQL. Other databases may use different methods (oracle doubles the quotes)
The column type that you should use to store text is either a TEXT or a BLOB type.
Read your database manual for the exact specs of each type to see which fits your needs best.
Also, when you store the textfile, it's only the CONTENT of the file that gets stored. If you want to store the filename too, you'll have to put that in a seperate field.