I have a script that I want to delete all files in a folder (taken from a database) except for one named thumb1.jpg
I have this, but this deletes all the files and a subfolder if there is one. How can I modify it to leave the folder and thumb1.jpg intact, but remove any other files in this folder?
if($folder!="" and file_exists($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder))
{
$dir = opendir ($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder);
while ($file = readdir ($dir))
{
if($file <> "." && $file <> "..")
{
if(is_dir($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder."/".$file))
{
$dir2 = opendir ($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder."/".$file);
while ($file2 = readdir ($dir2))
{
if($file2 <> "." && $file2 <> "..")
{
@unlink($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder."/".$file."/".$file2);
}
}
@rmdir($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder."/".$file);
}
else
{
@unlink($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder."/".$file);
}
}
}
@rmdir($_SERVER["DOCUMENT_ROOT"].site_root.site_upload_directory."/".$folder);
}
}
update 2 columns by doing inner 2-column query
Hi,
how to populate a drop down box
Hi buddies!
Need help making a script that moves data into acrhive table
Hi,I'm kinda new to php/mysqlAnd i wrote a simple script to store sales lead for a buisness and they are posted out into a table after they are submitted in a form. The page where you can see all your
Amend code to allow multiple attachments
Hi I have a php page that allows the user to browse to a file (image) then sumbit, the confirmation page then has the following code which uploads the said file to the hosting server, but also appends
Socket programming
Hello all,I have a PHP socket script. GPS trackers connect to this socket. IMEI verification takes place and if that is ok, the code is passed to a database. Also if the code contains alert-info, SMS
checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that would be great. I have search google and this forum but have not found what i am looking for.thankswhen
array_map() probably obvious mistake
The code below is part of a class to escape strings, but should also accept an array, using array_map() to do the job. Unfortunately, passing an array results in the original, unescaped array being
I think i'm using the syntax incorrectly
Hi Everyone!I'm new to this forum and a newbie with PHP - I'm glad I found this site - I hope to learn a lot! For my first and hopefully one of few questions, lol..I told my boss i'd help him out
Form errors in an array
I'm processing a form and putting the errors in an array. empty($errors) doesn't seem to do the trick when trying to check to see if the array is empty. Is my understanding of empty()incorrect? Each
Taking an HTML form and a PHP program and making it into one working file.
Hello, So I would like to display everything INSIDE a specific directory. In other words, I would like to display all file name's inside all subfolders in a specific directory. (NOT the subfolder