It is very easy to do, but how you approach it depends entirely on the complexity of the parsing required.
If you want more help you should give an example of the file you want to parse and the data you want to extract from it. I have attached a simple example of CSV parsing for you to see one approach.
<?php
$debug = 'test'; // while in 'test' mode it just echos the insert statements
// - set to NULL to exec queries
$record_delimiter = "\n";
$field_delimiter = ',';
$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = '';
if(is_uploaded_file ($_FILES['userfile']['tmp_name'])) {
// open uploaded file and read into a var
$filename = $_FILES['userfile']['tmp_name'];
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
// setup db connection
$db = @mysql_pconnect($db_host, $db_user, $db_pass)
or die('Failed to connect to db server.<br>MySQL error: '.mysql_error());
@mysql_select_db($db_name)
or die('Failed to select db.<br>MySQL error: '.mysql_error());
// nowcreate array - each element being a row from the file
$contents_array = explode($record_delimiter, $contents);
reset ($contents_array);
// for each row split into fields and write/execute insert statement
while (list ($key, $val) = each ($contents_array)) {
$fields = explode($field_delimiter, $val);
$sql = "INSERT INTO tbl_name(col1,col2,col3) VALUES('".trim($fields[0])."','".trim($fields[1])."','".trim($fields[2])."')";
if ($debug == 'test') {
echo $sql.'<br>';
} else {
$res = @mysql_query($sql, $db)
or die ('<b>Insert failed.</b><br>MySQL error: '.mysql_error().'<br>Query: '.$sql);
} // end else
} // end while
} else {
?>
<form action="<? echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Upload: <input name="userfile" type="file"><br><br>
<input type="submit" value="Upload and insert csv data">
</form>
<?
} // end else
?>
Hope this helps