doumu2172 2012-12-03 15:19 采纳率: 0%
浏览 12
已采纳

Zend框架传递隐藏字段和取消链接文件

I am working with Zend FW and deleting images from a form submitted in a view. I successfully delete all images name from the database, each one of them in the Array using their IDs.

What I can't solve is once the names are deleted how do I unlink each file form the folder?

I have an hidden fied as follow:

<input type="hidden" name="Image[]" value="<?php echo $this->escape($r['image']); ?>" />

And I know that In the controller I can call a file name using:

$images = $this->_getParam('image');

This is fine for one image but how do I unlink an Array of files? It is the first time that I come across this problem, please help.

I am trying to do something like this:

foreach ($images as $img) { 
            foreach(("/uploads/thumb}/{$img}") as $file) {

        unlink($file); 
         }
    }

I am probably doing something silly...apologies.

  • 写回答

2条回答 默认 最新

  • duanhe6799 2012-12-03 20:37
    关注

    Taking in consideration the help from vascowhite I managed to make it work this way. the simplest and abvious really:-

    foreach($images as $img) { 
            $file = "./uploads/thumb/$img";
            unlink($file); 
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程