I'm uploading the files successfully, but the file can not be renamed, returns a 0.txt name, or 0.png depending on the stretch, where am I going wrong?
<?
for ($i=1;$i<=1;$i++)
{
$arquivo = "arq".$i;
if (!empty($_FILES[$arquivo]['name']))
{
$fileName = $_FILES[$arquivo]['name'];
$fileTmp = $_FILES[$arquivo]['tmp_name'];
$fileType = $_FILES[$arquivo]['type'];
$fileSize = $_FILES[$arquivo]['size'];
$fileExt = substr($fileName, -4, 5);
$fileExt = str_replace(".", "", $fileExt);
$extFile = $fileExt;
$fileExt = ".".$fileExt;
$maxSize = "800000";
$hash = date("sm");
$nomeSemExt = preg_replace('/\.[^.]*$/', '', $fileName);
$fileNamex = strtolower(preg_match("/[^a-zA-Z0-9_.]/", "", strtr($nomeSemExt, "áàãâéêíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ", "aaaaeeiooouucAAAAEEIOOOUUC_")));
$local = "../arquivos/";
$novoNome = $fileNamex."".$fileExt;
$arqEX = "../arquivos/$novoNome";
if(file_exists($arqEX))
{
$novoNome = $fileNamex."_$hash".$fileExt;
}
move_uploaded_file( $fileTmp, "$local"."$fileName");
rename("$local"."$fileName", "$local"."$novoNome");
$local = substr($local, 3, 120);
$tipo = $fileExt;
if($extFile!='exe')
{
echo "Arquivo <b><a href=\"arquivos/$novoNome\" target=\"_blank\" style=\"color:#000;font-weght:normal;\" >$novoNome</a></b> anexado!";
echo "<input type=\"hidden\" name=\"uparquivo$i\" id=\"uparquivo$i\" class='txt03' value=\"$novoNome\">";
echo "<br><br>Nome do arquivo<br><input type=\"text\" name=\"title$i\" size=\"60\" id=\"title$i\" class=\"inputMd\" value=\"\">";
echo "<input type=\"hidden\" name=\"ext$i\" id=\"ext$i\" value=\"$extFile\">";
echo "<input type=\"hidden\" name=\"size$i\" id=\"size$i\" value=\"$fileSize\"> ";
echo "<a href=\"javascript:void(0)\" onClick=\"Load('delete&file=true&arq=$novoNome&i=1', 'upform1')\"><img src=\"images/delete.png\" class=\"img\"></a>";
}
else
{
echo "<script>alert(\"Arquivos com extesão .exe não são permitidos!\");</script>";
echo "<input type=\"file\" name=\"arq1\" id=\"arq1\" size=\"20\" onChange=\"enviaDados1('upform1')\">";
}
}
}
?>