无法在Codeigniter中取消链接文件

无法在Codeigniter中取消链接文件

本文介绍了无法在Codeigniter中取消链接文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的专案中,我在根目录中有一个资料夹 secure 。项目包如下:

In my project I have a folder secure in root. The project package looks like:

application
secure
system
...........

内部安全文件夹我正在使用

Inside secure folder I am uploading some images on form submit using

$config1['upload_path'] = './secure/';
$ext = end(explode(".", $_FILES['thumb_image']['name']));
$config1['file_name'] = time().$_FILES['thumb_image']['name'];
$config1['allowed_types'] = 'jpg|png|jpeg|gif|bmp|jpe|tiff|tif';
$this->load->library('upload', $config1);
$this->upload->initialize($config1);
$this->upload->do_upload('thumb_image');

并且它正常工作。现在在编辑细节时,使用另一种形式,如果我上传一个新的图像,而不是当前的图像文件,我想取消链接当前的一个,然后上传新的文件。

and it is working properly. Now while on editing the details, using another form, if I am uploading a new image instead of the current image file, I want to unlink the current one and then upload new file.

为此,我使用的代码:

unlink(base_url("secure/".$data['row']->videothumbnail));

我也尝试过

unlink('/secure/'.$data['row']->videothumbnail);

其中 $ data ['row'] - > videothumbnail) code>是来自数据库的当前图像文件。新文件已成功上传。但旧文件没有取消链接。我已将安全文件夹的权限设置为 777 。但是图像以只读权限上传。是因为这个,它没有解除链接?

where $data['row']->videothumbnail) is the current image file from database. New file is successfully uploaded. But old file is not getting unlinked. I have set the permission of secure folder to 777. But the images are uploaded with read only permission. Is it because of this, it is not getting unlinked?

任何人都可以帮我解决这个问题?

Can anyone help me to solve this?

先感谢。

推荐答案

尝试:

动态使用:

@chmod('./secure/'.$data['row']->videothumbnail, 0777);

然后尝试取消关联:

@unlink('./secure/'.$data['row']->videothumbnail);

这篇关于无法在Codeigniter中取消链接文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:38