Spectre
V2EX  ›  PHP

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

  •  
  •   Spectre · Jan 4, 2017 · 2530 views
    This topic created in 3416 days ago, the information mentioned may be changed or developed.

    $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 replies    2017-01-05 18:56:12 +08:00
    baocaixiong
        1
    baocaixiong  
       Jan 4, 2017
    试试 call_user_func(array($this, 'removeTrash'), $data)
    Spectre
        2
    Spectre  
    OP
       Jan 4, 2017
    @baocaixiong 是我上传的时候 upload 里有这个方法 老是提示错误 我看别人那边也没设置 callback 没报错。。
    realpg
        3
    realpg  
    PRO
       Jan 5, 2017
    跟 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
       Jan 5, 2017
    @realpg 传的是默认的 upload 里面的 callback false ,问题好像出在 whoops 上 会对这个报错。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5531 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 08:21 · PVG 16:21 · LAX 01:21 · JFK 04:21
    ♥ Do have faith in what you're doing.