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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.