I want to make a function to delete a file in my folder through php
. I've written the code based on suggestion from here, but eventually it is not deleting the file I intended to remove. It's removing other file instead.
Here's the code :
$file_name = $this->input->post('file_name'); //getting file name from view
$path_gse = realpath('file_upload/station_report/gse_serviceability/'.$file_name);
if(is_writable($path_gse)) {
unlink($path_gse);
}
In $file_name
variable I pass it from view with ajax
, I've tested it and it did return the correct file name. I really have no idea why this function delete the file that I don't intended to remove.
UPDATE
Here's the files in folder before I delete,
Then I delete a row number 3 from html table,
It suppose to delete a file named crew_conden-1801-Local_Time ver download tgl 18 Jan 18
, but here's what happened,
It deleted OTP Dashboard development
file instead of crew_conden-1801-Local_Time ver download tgl 18 Jan 18