php - Uploading large (~80Mb) text file and saving to database? -
i need create web page person can use select , upload text file (eg: csv) , have file imported backend mysql database.
this fine, , have php code - accept file upload, parse, save database.
the problem need reliable method allow user upload large files, potentially around 30 - 80mb, without timing out or failing during upload or save database.
other increasing upload limit , timeout settings, there other advice on how can ensure consistently reliable method ensure data uploaded?
the dataset changes daily, , previous day's data in database needs cleared out , replaced new day's data - vital no data lost during new upload.
i welcome advice of others how best achieve this, high degree of confidence data uploaded reliably , successfully, , how best clearing out of previous days data - ideally best check new data uploaded before clearing out , replacing previous data.
all suggestions welcome!
there stack overflow question confirm goleztrol's answer php timeout doesn't begin until after upload finished: php file upload affected or not max_input_time?
as processing data, if file in csv/tab-delimited or similar format matches table structure, fastest method use mysql's load data
statement: https://dev.mysql.com/doc/refman/5.5/en/loading-tables.html
for aspect of replacing data , making sure import successful before deleting old data, best answer question: mysql: truncate table within transaction? talks how can inserting data new table, once you've verified new data, renaming tables swap them. can safely delete old data. seems fluid way of accomplishing (keeping in mind truncate
not transaction-safe).
Comments
Post a Comment