This could be a PHP issue or a linux issue.
My form uses the following code to allow users to upload their banner and worked fine on my old server:
if ($_FILES["banner"]["name"]!="")
{
$folder_path = "images/server_banners/";
$myfileext=substr($_FILES["banner"]["name"], - 4,4);
$banner_file_path=$username."-".$server_id.$myfileext;
$file_path = $folder_path.$banner_file_path;
if (file_exists($file_path))
{
unlink($file_path);
move_uploaded_file($_FILES["banner"]["tmp_name"],$file_path);
}
else
{
move_uploaded_file($_FILES["banner"]["tmp_name"],$file_path);
}
$sql = mysql_query("UPDATE servers SET banner='".$banner_file_path."' WHERE id = '".$server_id."' and administrator = '".$_SESSION['valid']."'");
}
But it seems the images now cannot be overwritten? When I submit the form everything is fine as I can see the browser uploading the image by percentage - however the image is not stored IF a file already exists with the same name. Which means the script is working fine but there is some sort of permissions issue?
Just for a test I gave all folders and files 777 and the image still wasn't overwritten.
I then deleted the stored file and reverted back permissions and uploaded a new file and it worked fine.
Any ideas? Is there a way to ensure files can be overwritten in a certain directory?