 <p>Unless you are 100% rely on the user and it seems that you are not, it will be good not to blindly import uploaded file, but first to check if it's correct.</p> <p>To do it, you'll need to open and to read the file, e.g. with <code>fgetcsv</code> and to check the data consistency line-by-line.</p> <hr> <p>You can find a lot of examples on the web.</p> <p>Here are just some:</p> <ul> <li><a href="http://www.damnsemicolon.com/php/php-upload-csv-mysql" rel="nofollow">http://www.damnsemicolon.com/php/php-upload-csv-mysql</a></li> <li><a href="http://www.programmingfacts.com/import-csvexcel-data-mysql-database/" rel="nofollow">http://www.programmingfacts.com/import-csvexcel-data-mysql-database/</a></li> </ul>