I have a form where i get a filename from a inputbox. I create the a directory and change the extension form "gpx" to "xml" of the file before i upload the file to my directory. In php5 i need preg_replace, but in php i can't do it anymore.
I have this code: My old code is:
if (!file_exists($dirPath)) {
mkdir($dirPath, 0755,true);
}
$target = '/'.$mappe.'/';
$target = $dirPath .'/'. basename( $_FILES['gpsfilnavn']['name']);
$target = preg_replace("/(\w+).gpx/ie","$1.'.xml'",$target);
$xmlfil = $xmlfil . basename( $_FILES['gpsfilnavn']['name']);
$xmlfil = preg_replace("/(\w+).gpx/ie","$1.'.xml'",$xmlfil);
if(move_uploaded_file($_FILES['gpsfilnavn']['tmp_name'], $target)) {
echo "The file ". basename( $_FILES['gpsfilnavn']['name'])." has been uploaded";
Can anybody help me what i have to change?