It depends what you mean by I need to store that file in a MySQL database table.?
- If you mean store the entire file as a single opaque entity, then writing it to the file system and then using the DBs bulk insertion tool is the way to go.
Although I agree with others that there is little or no benefit and many downsides to storing BLOBs in relational DBs.
- If you mean that the file contains data as rows or records that need to be inserted into the table, then the best method will depend upon what format the data is in:
- If it is some easily parable form, eg. CSV or TSV, then again the write to file and bulk insert route is best.
- However, if the data needs more complex parsing/processing before the records are in a suitable form for input, then investigate CGI's upload() function which returns a filehandle from which you can read the data in chunks.
Alternatively, look at the CGI::upload_hook() function that allows you to register a callback that will be called with successive chunks of the file as it is uploaded.
See the CGI docs for more.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.