V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Spectre
V2EX  ›  PHP

Thinkphp 上传文件的一段代码问题

  •  
  •   Spectre · 2017-01-04 20:38:04 +08:00 · 2093 次点击
    这是一个创建于 2682 天前的主题,其中的信息可能已经有所发展或是发生改变。

    $data = call_user_func($this->callback, $file); if ($this->callback && $data) { if (file_exists('.' . $data['path'])) { $info[$key] = $data; continue; } elseif ($this->removeTrash) { call_user_func($this->removeTrash, $data); //删除垃圾据 } }

    错误提示: call_user_func() expects parameter 1 to be a valid callback, no array or string given 我按照文档来的 这边 callback 默认是 false 为什么还会提示错误啊

    4 条回复    2017-01-05 18:56:12 +08:00
    baocaixiong
        1
    baocaixiong  
       2017-01-04 21:32:24 +08:00
    试试 call_user_func(array($this, 'removeTrash'), $data)
    Spectre
        2
    Spectre  
    OP
       2017-01-04 21:37:39 +08:00
    @baocaixiong 是我上传的时候 upload 里有这个方法 老是提示错误 我看别人那边也没设置 callback 没报错。。
    realpg
        3
    realpg  
       2017-01-05 09:38:16 +08:00
    跟 thinkphp 没关系

    call_user_func() expects parameter 1 to be a valid callback, no array or string given


    call_user_func()需要第一个参数是合法的 callback ,你给的参数不是数组或者字符串
    这么明确了你先搞明白你传进去的东西是啥再说 trace 一下你传的第一个参数到底是啥
    Spectre
        4
    Spectre  
    OP
       2017-01-05 18:56:12 +08:00
    @realpg 传的是默认的 upload 里面的 callback false ,问题好像出在 whoops 上 会对这个报错。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5250 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 03:51 · PVG 11:51 · LAX 20:51 · JFK 23:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.