dongquelu1239 2018-10-15 08:37
浏览 28

PHP取消链接删除不正确的文件名

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, file before delete

Then I delete a row number 3 from html table, table stackoverflow

It suppose to delete a file named crew_conden-1801-Local_Time ver download tgl 18 Jan 18, but here's what happened,file after delete

It deleted OTP Dashboard development file instead of crew_conden-1801-Local_Time ver download tgl 18 Jan 18

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本