I am trying to modify the exenstion of a file, but whenever I make a file, it seems to be damaged.
$oldFileName = $targetDir . DIRECTORY_SEPARATOR . $fileName; $newString = preg_replace('"\.tmp$"', '.jpg', $oldFileName); rename($oldFileName, $newString);
The code works and changes the extension, but still the file appears to be damaged when it is downloaded.
The extension is .tmp and I am trying to change it to .jpg.
If I download .tmp and manually change it to .jpg, this works, but not when PHP does it.
Does anyone know why this might happen?
Thanks!
Kyle
source share