Jump to content

deleting file


zero_ZX

Recommended Posts

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.'"'))

Link to comment
https://forums.phpfreaks.com/topic/210733-deleting-file/
Share on other sites

Oh yea, your totally right, if I could just learn to read the errors more carefully :D 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?

Link to comment
https://forums.phpfreaks.com/topic/210733-deleting-file/#findComment-1099307
Share on other sites

Appears windows just sucks lol :D

 

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!

Link to comment
https://forums.phpfreaks.com/topic/210733-deleting-file/#findComment-1099326
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.