douchilian1009 2017-10-09 12:30
浏览 56

PHP - unlink('file_name')不工作[重复]

This question already has an answer here:

I have issues while trying to delete files in PHP, using unlink('filename'). I have tried with a complexe file and it didn't worked. I've been using relative paths as adviced on other post about this.

So i've made the simpliest script possible :

<?php
unlink("acs.gif");
?>

The script is located in the same folder as my asc.gif is, tho it still doesn't work. I've got no fatal errors, and a warning when enabling error_reporting() and init_set(). But the file is still there.

I've tried to set the permissions to both my folder, my image and my script to 0777 but it didn't help.

I'm getting quite confused about what is happening.

Do you guys have any ideas ?

</div>
  • 写回答

2条回答 默认 最新

  • dongyan3562 2017-10-09 12:33
    关注

    You shouldn't use relative path to file. If it lies in the same folder as a PHP script, use unlink(__DIR__ . '/' . $filename);. In other cases set a full path to unlink.

    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch