<?php
function addPoint( &$line )
{
$last = $line{ strlen( $line ) - 1 };
if ( ! in_array( $last, array( '.', '?', '!' ) ) )
{
$last .= '.';
}
}
if ( ! empty( $_FILES ) )
{
$data = $_FILES[ 'f' ];
$tmp = $data[ 'tmp_name' ];
if ( file_exists( $tmp ) )
{
if ( $data[ 'type' ] != 'text/plain' )
{
die( 'Incorrect file. <a href="'.getenv('REQUEST_URI').'">Retry</a>' );
}
$lines = array_map( 'trim', file( $tmp ) );
$lines = array_map( 'addPoint', $lines );
$content = join( "\n", $lines );
// Output fname here
$outName = dirname(__FILE__).'/output.txt';
move_uploaded_file( $content , $outName );
}
}
?>
<form method="post">
<input type="file" name="f" />
</form>