Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="" method="post" enctype="multipart/form-data">
- <p>File: <input name="file" type="file" /></p>
- <p><input name="submit" type="submit" value="Parse" /></p>
- </form>
- <?php
- if(isset($_POST['submit'])) {
- define('ROOT_DIR', dirname(__FILE__) . '/');
- $valid_extensions = array('txt');
- if($_FILES['file']['error'] === UPLOAD_ERR_OK) {
- $file_extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
- if(in_array($file_extension, $valid_extensions)) {
- $filename = substr(md5(date(His)), 5, 5) . '_' . $_FILES['file']['name'];
- $filename = trim($filename);
- if(move_uploaded_file($_FILES['file']['tmp_name'], $filename)) {
- $file = file($filename);
- $array = array();
- foreach($file as $line) {
- $array[] = 'старт' . base64_encode ($line);
- }
- $fp = fopen($filename, "w");
- foreach($array as $line) {
- fwrite($fp, $line."\r\n");
- }
- echo '<a href="' . $filename . '">' . $filename . '</a>';
- }
- else
- $info = 'Error #1';
- }
- else
- $info = 'Error #2';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement