troubleshooting Question

PHP unlink command and using the second parameter

Avatar of dogsareit
dogsareitFlag for United States of America asked on
4 Comments1 Solution13 ViewsLast Modified:
I have been wondering about the second parameter of the unlink command.
When I use the unlink command, I always use the realpath of the file location.
What exactly does the second parameter do and should I be using it ?
This is how I currently use it:
   $folder_path = '';
   $files = '';
   $folder_path = $_SESSION['TmpWorkPdfsToUpload'];
   $files = glob($folder_path . '/*');  
   foreach($files as $file)
     if (is_file($file))
         $strRealLocation = realpath($file);
          echo '<BR>DELETED FILE: ' . $strRealLocation . PHP_EOL;
          }catch(Exception $e){
            echo 'Message: ' . $e->getMessage() . PHP_EOL;
         echo '<BR>NO FILES TO DELETE';
Thank you in advance.

Yujin Boby
Linux Server Admin

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros