使用codeigniter在本地服务器上进行文件操作
在我的项目中,我有一个名为portfolio的表,它有一个名为images的属性。在该属性中,我保存图像位置,例如“uploads/1.jpg”。 我的文件上传问题没有任何问题。
当我从数据库表中删除一行时,我只是删除该行,但该文件仍然存在于本地的 uploads 目录中断绝。 当我从数据库中删除该行时,我也想删除该文件。
我在codeigniter文档中看到了ftp类,但是文档说我需要配置ftp主机。但目前我正在为我的项目使用本地主机服务器wamp,并且尚未将其上传到主服务器中。那么,当我使用 codeigniter 从数据库中删除行时,如何从其目录中删除文件?有人可以帮忙吗?
我正在为我的项目使用 codeigniter 2.1.0 和 mySQL 数据库。
in my project i have a table named portfolio, which has an attribute called images. in that attribute i am saving the image location like 'uploads/1.jpg'. i don't have any problem with file uploading issue.
when i delete an row from my database table, i am only deleting the row but the file still exists in the uploads directory in my local sever. i want to delete the file also, when i am deleting the row from the database.
i have seen the ftp class in codeigniter documentation, but the document says that i need to configure a ftp host. but currently i am using the localhost server wamp for my project and haven't uploaded it yet in the main server. so, how do i delete a file from it's directory when i am deleting the row from the database using codeigniter? can anyone help?
i am using codeigniter 2.1.0 and mySQL database for my project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
unlink()
函数。http://www.php.net/manual/en/function.unlink.php
例如:
Use the
unlink()
function.http://www.php.net/manual/en/function.unlink.php
Ex: