zero_ZX Posted August 14, 2010 Share Posted August 14, 2010 Hi, When i launch my code i get the following php error: Warning: unlink(../files/"yCUuH0223e3d6d046acb58678fbb54042e0fe.pdf") [function.unlink]: Invalid argument in C:\xampp\htdocs\intra\VVS\admin\fakture-edit.php on line 74 But in the dir: C:\xampp\htdocs\intra\VVS\files\ The file exists.. here's my php code: $id = mysql_real_escape_string($_GET['id']); $fil = mysql_real_escape_string($_GET['fil']); $result2 = mysql_query("SELECT * FROM fakture WHERE id=('$id') LIMIT 1"); $row2 = mysql_fetch_array($result2); if ($_GET["op"] == "process") { if (!unlink('../files/"'.$fil.'"')) Quote Link to comment https://forums.phpfreaks.com/topic/210733-deleting-file/ Share on other sites More sharing options...
Alex Posted August 14, 2010 Share Posted August 14, 2010 Your path is coming out looking like ../files/"somefile" with the quotes in the name. Try this: if (!unlink('../files/'.$fil)) Quote Link to comment https://forums.phpfreaks.com/topic/210733-deleting-file/#findComment-1099300 Share on other sites More sharing options...
zero_ZX Posted August 14, 2010 Author Share Posted August 14, 2010 Oh yea, your totally right, if I could just learn to read the errors more carefully Thanks a lot. I'm getting a permission denied message on a windows system.. the process running php has full access to the file, so I don't really understand that, can any one help me on that matter? Quote Link to comment https://forums.phpfreaks.com/topic/210733-deleting-file/#findComment-1099307 Share on other sites More sharing options...
Alex Posted August 14, 2010 Share Posted August 14, 2010 Make sure the file trying to delete the other file has permission. Quote Link to comment https://forums.phpfreaks.com/topic/210733-deleting-file/#findComment-1099309 Share on other sites More sharing options...
zero_ZX Posted August 14, 2010 Author Share Posted August 14, 2010 Appears windows just sucks lol I first tried to change ownership, which didn't work well, but if you move out of the working directory, and change it to the one you want to operate in, then it actually works.. So my fix is: if ($_GET["op"] == "process") { $olddir = getcwd(); // Save the current directory chdir('../files'); if (!unlink($fil)) Thanks for everything! Quote Link to comment https://forums.phpfreaks.com/topic/210733-deleting-file/#findComment-1099326 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.