Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $file1_name = basename( $_FILES['file1']['name'] );
- $file1_name = substr(md5(rand()), 0, 5). "-" .$file1_name;
- $file2_name = basename( $_FILES['file2']['name'] );
- $file2_name = substr(md5(rand()), 0, 5). "-" .$file2_name;
- if (move_uploaded_file($_FILES['file1']['tmp_name'], $file1_name) && move_uploaded_file($_FILES['file2']['tmp_name'], $file2_name) ) {
- $file1 = file($file1_name, FILE_IGNORE_NEW_LINES);
- $file2 = file($file2_name, FILE_IGNORE_NEW_LINES);
- sort($file1);
- sort($file2);
- $diff = array_diff($file2, $file1);
- array_unshift($diff, $_POST['csv_cols']);
- $output = substr(md5(rand()), 0, 5). "-output.csv";
- file_put_contents($output, implode(PHP_EOL, $diff));
- unlink($file1_name);
- unlink($file2_name);
- header('Content-Description: Download ' . $output);
- header('Content-Type: application/force-download');
- header("Content-Type: application/download");
- header("Content-Length: " . filesize($output));
- header("Content-disposition: attachment; filename=\"" . basename($output) . "\"");
- readfile($output);
- unlink($output);
- exit;
- } else {
- echo "An unknown error occured";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement