-1

I have read a lot of pages about this but I just can't get it to work.
I have a file on my server that needs to be deleted after the file has been imported.

The file is a .csv file and opened with fopen.

After import the file is closed with fclose.

Now I want to delete the file with:

chown($filepath, 666);

if (file_exists($filepath))
{
    if (unlink($filepath))
    {   
            echo "success";
    }
    else
    {
            echo "fail";    
    }   
}
else
{
        echo "file does not exist";
}

It keeps failing with file does not existbut I don't know why. I use the exact same path to import

M.

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Interactive
  • 1,474
  • 5
  • 25
  • 57

1 Answers1

0

You cant directly access the file using URL

$filepath = 'http://www.xxx.nl/files/testing.csv';

To access your file, use

$filepath = ./files/testing.csv

so file structure would be

- file
   - testing.csv
- index.php
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85