Hello,
I have the following script for an upload sequence that when I upload a file, the directory and file that it makes, will not be deleted. I ftp-ed into the server and it just says that I dont have permissions to delete the File. I could rename the folder, but that's it. Is my code off, or do I need to delete the files usign PHP, and if so, how do I do that?
if(isset($uploadpic)) {
$username = "cmdr_bond";
$tmp = explode ( '.', $_FILES['uploadpic']['name']);
$fileext = $tmp[count($tmp)-1];
$allowedexts = array("image/gif", "image/jpg");
$upload_dir = "../images/users/" . $username . "/";
$temp_name = $_FILES['uploadpic']['tmp_name'];
$file_name = $_FILES['uploadpic']['name'];
$file_name = stripslashes($file_name);
$file_path = $upload_dir.$file_name;
if (in_array($_FILES['uploadpic']['type'], $allowedexts)) {
if (!is_dir($upload_dir)) {
if (!mkdir($upload_dir,0777))
die ("upload_files directory doesn't exist and creation failed");
// if (!chmod($upload_dir,0777))
//die ("change permission to 777 failed.");
}
move_uploaded_file($_FILES['uploadpic']['tmp_name'], $upload_dir.$file_name);
$sql = ....// Here I just add that a row in my table about the pic
$result = mysql_query($sql) or die(mysql_error());
echo "Received {$_FILES['uploadpic']['name']} - its size is {$_FILES['uploadpic']['size']} with extension $fileext";
} else {
echo "You must upload a gif or jpg file.";
}
}