使用codeigniter在本地服务器上进行文件操作

发布于 2025-01-05 08:06:37 字数 472 浏览 1 评论 0原文

在我的项目中,我有一个名为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡莣 2025-01-12 08:06:37

使用 unlink() 函数。
http://www.php.net/manual/en/function.unlink.php

例如:

unlink('path/to/file.jpg');

Use the unlink() function.
http://www.php.net/manual/en/function.unlink.php

Ex:

unlink('path/to/file.jpg');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文