Skip to content

Instantly share code, notes, and snippets.

@umairidrees
Last active December 22, 2015 03:38
Show Gist options
  • Save umairidrees/6411206 to your computer and use it in GitHub Desktop.
Save umairidrees/6411206 to your computer and use it in GitHub Desktop.
<?php
if(isset($_POST['submitcsv'])){
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file,"r");
while($file = fgetcsv($handle,1000, ",")){
$sql = mysql_query("INSERT INTO `table`(`value-1`, `value-2`) VALUES ('$file[0]','$file[1]')");
};
}
?>
<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="file" >
<input type="submit" name="submitcsv" value="Import" >
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment