Forum Moderators: coopster
if (file_exists("C:\KPIUpload\Data.xls")) {
unlink("C:\KPIUpload\Data.xls");
}
Is it anyhting to do with the full folder reference?
if((!empty($_FILES["uploaded"])) && ($_FILES['uploaded']['error'] == 0)) {
//Check if the file is XLS image and it's size is less than 350Kb
$filename = basename($_FILES['uploaded']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "xls") && ($_FILES["uploaded"]["size"] < 10000000)) {
//Determine the path to which we want to save this file
$newname = dirname(__FILE__).'/upload/'.$filename;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname)) {
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['uploaded']['tmp_name'],$newname))) {
$msg = "<font color='blue'>It's done! The file has been saved as:<br /> ".$_FILES['uploaded']['name']."</font>";
copy ("$newname","C:/KPIUpload/Data.xls");
} else {
echo "<font color='red'>Error: A problem occurred during file upload!</font>";
}
} else {
$msg = "<font color='red'>Error: File ".$_FILES["uploaded"]["name"]." already exists</font>";
}
} else {
$msg = "<font color='red'>Error: Only .xls files under 10Mb are accepted for upload</font>";
}
} else {
$msg = "<font color='red'>Error: No file uploaded</font>";
}
}