Do so:
<form enctype="multipart/form-data" method="POST">
<input type="file" name="txt">
<input type="submit">
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$file = $_FILES['txt'];
$dir = 'tests/'; // ajustar nome diretório destino
$fileName = 'new_txt.txt'; // ajustar nome do ficheiro
move_uploaded_file($file['tmp_name'], $dir.$fileName);
$text = utf8_encode(file_get_contents($dir.$fileName);
$search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u");
$replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u");
$new_text = str_replace($search, $replace, $text);
$file = fopen($dir.$fileName, 'w');
fwrite($file, $new_text);
fclose($file);
echo 'VELHO TEXTO:<br><br>' .$text. '<br><br>';
echo 'NOVO TEXTO:<br><br>' .file_get_contents($dir.$fileName);
}
Adjust where I commented "adjust..."
Stored in an array? What do you mean? One line per input?
– Miguel
It’s like, I don’t know if
array
but I need to read the file to get the right accents ? Is there any other way ?– KevinF
But want to upload right first?
– Miguel
Yeah, that’s right.
– KevinF