-
Posts
4,953 -
Joined
-
Last visited
Everything posted by darkfreaks
-
try this <?php $file = "test.txt"; if (!unlink($file)) { echo ("Error deleting $file"); } else { echo ("Deleted $file"); } ?>
-
go back to the other function it was helpful and we need to use PHP function unlink to delete files.
-
try: <?php $dir = the target directory $DeleteMe = false; function SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, false); } if ($DeleteMe){ closedir($dh); @rmdir($dir); } } //SureRemoveDir('EmptyMe', false); //SureRemoveDir('RemoveMe', true); ?>
-
it will only delete the images but you must put false in the sureremovedir function as well.
-
if it returns true it will delete everything including the folder if false it will just delete all images.
-
<?php $dir = the target directory $DeleteMe = if true delete also $dir, if false leave it alone function SureRemoveDir($dir, $DeleteMe) { if(!$dh = @opendir($dir)) return; while (($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true); } if ($DeleteMe){ closedir($dh); @rmdir($dir); } } //SureRemoveDir('EmptyMe', false); //SureRemoveDir('RemoveMe', true); ?>
-
the functions claims to get rid of everything inside the folder and the folder itself
-
ah screw it try this instead see if it works any better: <?php function full_rmdir($dirname) { if ($dirHandle = opendir($dirname)) { $old_cwd = getcwd(); chdir($dirname); while ($file = readdir($dirHandle)) { if ($file == '.' || $file == '..') continue; if (is_dir($file)) { if (!rmdir_rf($file)) return false; } else { if (!unlink($file)) return false; } } closedir($dirHandle); chdir($old_cwd); if (!rmdir($dirname)) return false; return true; } else { return false; } } ?>
-
it doesnt delete anything it just says deleting file.jpg but it doesnt?
-
which file?
-
alright ill be right here :-\
-
cool glad i was able to help man < /feels useful >
-
you put the directory and file define at the top of the code? paste the code
-
hope it works
-
the code i just posted above i left out the path code to specify the directory :-\
-
oops try adding $dir = "/path/to/base/dir"; appearantly i left that line out so it wouldnt read the directory path and wouldnt do anything.
-
weird so it didnt work at all?
-
not sure if thi will help but i got this from php.net when i looked up opendir delete <?php recursive_delete($dir); function recursive_delete( $dir ) { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false ) { if( $file != "." && $file != ".." ) { if( is_dir( $dir . $file ) ) { echo "Entering Directory: $dir$file<br/>"; recursive_delete( $dir . $file . "/" ); echo "Removing Directory: $dir$file<br/><br/>"; rmdir( $dir . $file ); } else { echo "Deleting file: $dir$file<br/>"; unlink( $dir . $file ); } } } closedir($dh); } } } ?>
-
<?php if (!isset($_GET['del'])){ echo "Could not Delete the file!"; } else { $file = $_GET['del']; } ?>
-
<?php (!isset($_GET['del'])){ echo "Could not Delete the file!"; } else { $file = $_GET['del']; } ?>
-
oops sorry my keyboard is being weird anyway i was trying to say do a mysql_query to select the delete field and grab it that way.
-
ty doing a query and selecting it that way?
-
please list the errors so we know what to look for?
-
did you try replacing $_GET with $_REQUEST ?