Jump to content

Problem Using PHP exec() To Delete Subdirectory


OtagoHarbour

Recommended Posts

I use the following code to delete a subdirectory in the user's directory on a Windows system. $setDir= "f:\\ServerDirectory\\" . $_SESSION['UserName'] . "\\" . $setName; $str="del/q " . $setDir; echo "Delete string: " . $str . "<br \>"; $Result=exec($str, $output, $return); echo "Delete status:" . $output . " " . $return . "<br \>";The screen output is as follows.Delete string: del/q f:\ServerDirectory\UserDir\SubDirDelete status:Array 0Unfortunately, the subdirectory is not deleted.I would be grateful if someone could tell me what I am doing wrong.Thanks,Peter.

Link to comment
Share on other sites

What if you do this:print_r($output);It sounds like there is no output from the command.Does the command work if you run it in a command prompt manually?
Sorry. It was my mistake. I was supposed to be usingrmdir/s/qinstead ofdel/qThe output from print_r($output);wasArray ( ) Thank you for your help,Peter.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...