This might be a problem with other things, as your logic seems to be correct. Firstly,
rename("$oldfile","$newfile");
it should be:
rename($oldfile,$newfile);
and
$oldfile = "../wallpapers/temp-uploaded/".$file ;
it should be:
$oldfile = '../wallpapers/temp-uploaded/'.$file ;
since there is no need for additional interpolation. Will accelerate. Source: Benchmark test (see "Double (") vs. single (") quotes"). here .
,, :
echo "[$oldfile][$newfile]";- , .
var_dump(file_exists($oldfile),file_exists($newfile)) true, falsefile_get_contents($oldfile);?file_put_contents($newfile, file_get_contents($oldfile));- , .
chmod 777. - :
if ( file_exists($newfile) ) { unlink($newfile); }, , , . , - , . .
.
, % xx, :
$file = trim(urldecode($file));
:
$newfile = '../wallpapers/temp-uploaded/'.preg_replace('/[\\&\\%\\$\\s]+/', '-', $file);
:
$newfile = '../wallpapers/temp-uploaded/'.preg_replace('/[^a-zA-Z0-9_\\-\\.]+/', '-', $file);
\\, . , , , , , !;-)