Skip to content

Instantly share code, notes, and snippets.

Created July 26, 2012 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3179506 to your computer and use it in GitHub Desktop.
Save anonymous/3179506 to your computer and use it in GitHub Desktop.
stdin
<?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
$file = $_FILES["file"];
var_dump($_FILES["file"]);
$memberID = $_SESSION["SESS_MEMBER_ID"];
if ($file["type"] == "text/plain")
{
if ($file["error"] > 0)
{
echo "Return Code: " . $file['error'] . "<br />";
}
else
{
dbConnect();
mysql_select_db('mailList') or die(mysql_error());
$tmp_name = $file["tmp_name"];
$presql = "CREATE TABLE IF NOT EXISTS `{$memberID}` (id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE)";
$sql = <<<EOF
LOAD DATA LOCAL INFILE '{$tmp_name}'
ALTER TABLE `{$memberID}` ADD {$file} VARCHAR(60);
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\''
LINES TERMINATED BY "\\r\\n"
IGNORE 1 LINES
EOF;
mysql_query($presql);
mysql_query($sql);
//var_dump($sql);
echo '$sql';
if(mysql_error())
{
echo(mysql_error());
}
else
{
print('Import of campaign emails sucessfull into mysql table.');
}
}
}
else
{
print('Invalid file type. Please make sure it is a text file.');
}
}
//var_dump($_FILES);
uploadList();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment