Fw: [PHP] unlink ($files);
Hi, You can use the backtick operator to delete whatever you have permissions to delete: $directory = path/*.*; `rm -rf $directory`; They aren't quotes, they are backticks (to the left of the 1 key on most keyboards). It is very useful for any command line stuff you have permissions to do. Brian Allen [EMAIL PROTECTED] Paul Nicholson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey, You can't delete the files all at onceyou have to delete them one by one or use this function that will remove full directories. - - function force_rmdirs($dir) { $dh = opendir($dir); while(false !== ($file = readdir($dh))) { if($file != '.' $file != '..') { $path = $dir .'/'. $file; if(is_dir($path)) { force_rmdirs($path); } else { unlink($path); } } } closedir($dh ); return rmdir($dir); } - - HTH! ~Paul On Wednesday 08 January 2003 12:29 am, [EMAIL PROTECTED] wrote: Ok, Jason, here's another one! I think I've read how to delete a file. I need to delete 25 files, then do a rmdir(blah); Line 16: $directory = path/*.*; Warning: Unlink failed (No such file or directory) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 16 Warning: RmDir failed (File exists) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 17 Thanks - -- ~Paul Nicholson Design Specialist @ WebPower Design [EMAIL PROTECTED] www.webpowerdesign.net The webthe way you want it! It said uses Windows 98 or better, so I loaded Linux! Registered Linux User #183202 using Register Linux System # 81891 -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE+G8/JDyXNIUN3+UQRAmd/AJ42CW5HDYEQ1dvf/m5CLynoqGekwgCdE5T2 rxlRjVBaFNIhQGFQc38ylks= =mJq1 -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink ($files);
Can't do wildcards like * because thats something that as I found out a few days ago, is expanded by the shell into a full command, so because your not running a shell, it can't be expanded and the raw unlink call to *.* fails because the unlink function doesn't understand wildcards. If you really want to do a recursive deletion (i.e., remove both a directory and everything under it) you could use: exec(/bin/rm -rf path/$name-of-dir-to-be-erased); Just be very sure about what your doing (multiple checks on the variable's value to make sure your not erasing anything you don't want to) cause this command, when executed with the proper permissions, will kill any directory and everything under it. On Wed, 2003-01-08 at 00:29, [EMAIL PROTECTED] wrote: Ok, Jason, here's another one! I think I've read how to delete a file. I need to delete 25 files, then do a rmdir(blah); Line 16: $directory = path/*.*; Warning: Unlink failed (No such file or directory) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 16 Warning: RmDir failed (File exists) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 17 Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc signature.asc Description: This is a digitally signed message part
Re: [PHP] unlink ($files);
That will usually work on Unix but will not work on Windows. Rather than executing an external program you can use PHP itself to do a recursive delete. There are examples at http://www.php.net/manual/en/function.rmdir.php if you read the user notes you will see several posts about doing this. Jason 2003-01-08 at 07:24, Adam Voigt wrote: Can't do wildcards like * because thats something that as I found out a few days ago, is expanded by the shell into a full command, so because your not running a shell, it can't be expanded and the raw unlink call to *.* fails because the unlink function doesn't understand wildcards. If you really want to do a recursive deletion (i.e., remove both a directory and everything under it) you could use: exec(/bin/rm -rf path/$name-of-dir-to-be-erased); Just be very sure about what your doing (multiple checks on the variable's value to make sure your not erasing anything you don't want to) cause this command, when executed with the proper permissions, will kill any directory and everything under it. On Wed, 2003-01-08 at 00:29, [EMAIL PROTECTED] wrote: Ok, Jason, here's another one! I think I've read how to delete a file. I need to delete 25 files, then do a rmdir(blah); Line 16: $directory = path/*.*; Warning: Unlink failed (No such file or directory) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 16 Warning: RmDir failed (File exists) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 17 Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink ($files);
Ok, Jason, here's another one! I think I've read how to delete a file. I need to delete 25 files, then do a rmdir(blah); Line 16: $directory = path/*.*; Warning: Unlink failed (No such file or directory) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 16 Warning: RmDir failed (File exists) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 17 Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink ($files);
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey, You can't delete the files all at onceyou have to delete them one by one or use this function that will remove full directories. - - function force_rmdirs($dir) { $dh = opendir($dir); while(false !== ($file = readdir($dh))) { if($file != '.' $file != '..') { $path = $dir .'/'. $file; if(is_dir($path)) { force_rmdirs($path); } else { unlink($path); } } } closedir($dh ); return rmdir($dir); } - - HTH! ~Paul On Wednesday 08 January 2003 12:29 am, [EMAIL PROTECTED] wrote: Ok, Jason, here's another one! I think I've read how to delete a file. I need to delete 25 files, then do a rmdir(blah); Line 16: $directory = path/*.*; Warning: Unlink failed (No such file or directory) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 16 Warning: RmDir failed (File exists) in /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line 17 Thanks - -- ~Paul Nicholson Design Specialist @ WebPower Design [EMAIL PROTECTED] www.webpowerdesign.net The webthe way you want it! It said uses Windows 98 or better, so I loaded Linux! Registered Linux User #183202 using Register Linux System # 81891 -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE+G8/JDyXNIUN3+UQRAmd/AJ42CW5HDYEQ1dvf/m5CLynoqGekwgCdE5T2 rxlRjVBaFNIhQGFQc38ylks= =mJq1 -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php