Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $type = $_POST['mimetype'];
- $xhr = $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
- if( !($_FILES['file']['error'] == 4) ) {
- foreach($_FILES as $file) {
- $n = $file['name'];
- $s = $file['size'];
- $row = 0;
- ini_set('auto_detect_line_endings',TRUE);
- $filename = $file['tmp_name'];
- $handle = fopen($filename, "r");
- $contents = "<tbody>";
- //$contents = "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"css/emailList.css\" />\r\n<table cellspacing=\"0\" border=\"0\" align=\"left\" id=\"tblDisplay\" cellpading=\"0\" class=\"tblDisplayEmail\" style=\"font-family: verdana; font-size: 10px; width:485px;\">\r\n";
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
- if ($row == 0) {
- // this is the first line of the csv file
- // it usually contains titles of columns
- $num = count($data);
- $row++;
- //$contents = $contents . "<thead>\r\n<tr id=\"chkrow\" class=\"trBorder\">\r\n" . "<th><input type=\"checkbox\" id=\"checkall\" /></th> <th> </th> <th style=\"text-align: left;\">name</th> <th style=\"text-align: left;\">email</th>\r\n" . "</tr>\r\n</thead>\r\n<tbody id=\"tblDisplayBody\">\r\n";
- }
- else {
- // this handles the rest of the lines of the csv file
- $num = count($data);
- $row++;
- if( filter_var($data[1], FILTER_VALIDATE_EMAIL) != false ) {
- if(strlen($data[0]) == 0) {
- $data[0] = "No Name";
- }
- if(strlen($data[0]) > 31) {
- $data[0] = substr($data[0], 0, 30) . ".";
- }
- $contents = $contents . "<tr class=\"trBorderLight\">\r\n<td style=\"text-align: center;\"><input type=\"checkbox\" value=\"$row\" name=\"cvsEmail\" /></td> <td> </td> <td style=\"text-align: left;\">$data[0]</td> <td style=\"text-align: left;\">$data[1]</td>\r\n</tr>\r\n";
- }
- } // end ELSE
- } // end WHILE
- //$contents = $contents . "</tbody>\r\n</table>\r\n";
- $contents = $contents . "</tbody>\r\n";
- fclose($handle);
- ini_set('auto_detect_line_endings',FALSE);
- // Echo the files contents
- echo $contents;
- if (!$n) continue;
- //echo "File: $n ($s bytes)";
- } // end FOREACH
- } // end if( !($_FILES['file']['error'] == 4) )
- else { var_dump($_POST); echo "<br><hr>"; var_dump($_FILES); }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement