I need to run a command via shell which may have an accent (involves filename) by PHP. Printing the command and running it in hand it runs with the accent, but with shell_exec
it does not run. If I take the accent from the file name it runs the right command with shell_exec
, but I can not really rename the file.
<?php
header("Content-Type: text/html; charset=ISO-8859-1",true);
$path = "C:\Users\gabriela.mattos\Desktop\audios\";
$diretorio = dir($path);
while($arquivo = $diretorio -> read()){
if ($arquivo != "." && $arquivo != ".."){
$arquivo2= (utf8_encode($arquivo));
$arquivo2 = str_replace(" ","_",$arquivo2);
$arquivoConvertido = str_replace(".mp3",".avi",$arquivo2);
echo shell_exec(utf8_encode("ffmpeg -loop 1 -y -i C:\Users\gabriela.mattos\Pictures\logo.jpg -i ".$path.$arquivo2." -shortest -acodec copy -vcodec mjpeg ".$path.$arquivoConvertido.""));
}
}
$diretorio -> close();
?>