I've searched everywhere trying to figure this out. And since im fairly new to php, i haven't had much luck. I'm using CcMail to collect email addresses. One of the functions is the ability to import a csv list of email addresses. The code was not doing anything so i followed some advice and changed the $HTTP_POST_FILES values to just $_FILES and it finally gave me an error message but im still not able to get the addresses uploaded. The import.php file im using is a bit long so i'll only post the part i think is giving me trouble. There is a lot more code before all of this so let me know if you need me to post it.
//Retrieving users list...
elseif (isset($HTTP_POST_FILES['imported_file']['name']) && is_uploaded_file($HTTP_POST_FILES['imported_file']['tmp_name']))
{
$trimmed_address_array = array();
$file_address_array = fopen($HTTP_POST_FILES['imported_file']['tmp_name'], "r");
$list = fread($file_address_array, filesize($HTTP_POST_FILES['imported_file']['tmp_name']));
//Processing retrieved list
$list = str_replace(";", ",", str_replace("'", "", str_replace("\"", "", $list))); //removes " and ' and replaces ";" with ","
$typed_address_array = explode("\n", $list);
foreach ($typed_address_array as $item){ //foreach line
$split_line = explode(",", $item); //split line by commas
foreach ($split_line as $to_validate) if(validate_email(trim($to_validate))) array_push ($trimmed_address_array, trim($to_validate)); //add validated addresses
}
$trimmed_address_array = array_unique($trimmed_address_array);
if (count($trimmed_address_array) > 0) {
print "CcMail retrieved the following valid addresses:<br><br></b>";
foreach ($trimmed_address_array as $item) print "$item<br>";
print "<form action=\"$PHP_SELF?option=import\" method=\"post\"><br><br><input class=\"button\" type=\"submit\" value=\"Proceed\">";
$cripted_address_array = array();
foreach ($trimmed_address_array as $item) array_push($cripted_address_array, $crypt->encrypt ($pass, $item));
$_SESSION['imported_addresses_array'] = $cripted_address_array;
}
else print 'No valid address retrieved.<br></b>Please edit your file in order to match a simple list, and retry.<b><br><a href="?option=import" class="link">Retry</a>';
}
else {
print"You can Import a list of Users or a CcMail backup file.</b><br>
You should be able to retrieve informations from virtually any plain text file, from a normal list to a CSV.<br>If your Users are not retrieved successfully, please edit your file in order to match a simple list, and retry.<br><br><br>
<form enctype=\"multipart/form-data\" action=\"$PHP_SELF?option=import\" method=\"post\">";
print'<table border="0" cellpadding="0" cellspacing="0" width="100"><tr>
<td></td><td><div class="standard">Import addresses from a generic plain text file (a simple list, a CSV...)</td></tr>
<tr><td><div class="standard">
<b>1) Generic text file </b><br><br></div></td>
<td valign="top" align="right"><input class="tbox_max" name="imported_file" type="file" size="30"><br><br></td></tr>
<tr><td></td><td><div class="standard">Restore a CcMail Backup file</td></tr>
<tr><td><div class="standard">
<b>2) CcMail Backup file </b><br><br></div></td>
<td valign="top" align="right"><input class="tbox_max" name="ccmail_backup" type="file" size="30"></td></tr>
<tr><td colspan="2" align="right"><br><br><input class="button" type="submit" value="Proceed"></td></tr></table>
</form>';
}
?>