douchen7555 2016-12-06 07:46
浏览 15

无法将图像文件名添加到数据库中

In the code below, I am using the Upload class from verot.net/php_class_upload.htm. I can't get $q->update_single_field(etc) to run, and I suspect it has to do with there being a period in the string and something that ought to be done with quotations, but I can't figure it out. That method has worked fine in other contexts, and it also works if I replace the variable with a literal string.

if ($_FILES['cover']['name']) {
        $f = new Upload($_FILES['cover']); 
        if ($f->uploaded) {
            $f->Process('/home/intuitodev/public_html/plish/images/covers');
            if ($f->processed) {
                $uploaded_cover = $f->file_dst_name;
                $q->update_single_field('publications',$pub_id,'publication_cover',$uploaded_cover); 
                echo '<br />Pub ID: '.$pub_id;
                echo '<br />Uploaded Cover: '.$uploaded_cover;
            } else {
                echo 'error : ' . $f->error;
            }
        } 
    }

FYI, here is the method I use for updating. It works fine on anything other than that file variable:

    function update_single_field($table,$row,$field,$data) {
    $stmt = $this->pdo->prepare("UPDATE {$table} SET {$field} = :data WHERE id = :id");
    $stmt->execute(array(':data'=>$data,':id'=>$row));
}

Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?