多次上传保存并节省数据库错误

时间:2012-05-02 00:45:40

标签: php

我有一些问题你在多次保存数据库时遇到过一些问题吗?我的问题是这个,我有一个名为“album”的数据库,其中的字段是'album_id,album_title,album_user'。

html输出会有一个登录部分,其中有一个输入类型文件,你想要添加更多文件,一旦你上传它。将存储一组名称的数组,并且该数组将是我们的问题所在的以多种格式保存文件的队列。它说和数据库的错误是sql指定两次。你有一个想法如何使用PHP保存多个?

代码将是这样的。

    <?php
class Album extends olib{

    function __construct(){
        parent::olib();
    }       

    function upload_submit() {
        $allow = array("jpg","png","gif");
        $directory = "upload";
        $pictures = array();
        $counter = 0;
        $error = '';
        if($this->jpost('upload')) {
            for($getupload = 0;$getupload<count($_FILES['uploadpictures']['name']);$getupload++){           
                $extension = end(explode(".",$_FILES['uploadpictures']['name'][$getupload]));
                if(in_array(strtolower($extension),$allow)){
                    if(move_uploaded_file($_FILES['uploadpictures']['tmp_name'][$getupload],$directory."/".$_FILES['uploadpictures']['name'][$getupload])){
                        $pictures[$getupload] = $_FILES['uploadpictures']['name'][$getupload];
                        $counter++;
                    //  $this->save_user_album($_FILES['uploadpictures']['name'][$getupload],$this->setSession('user_id'));
                    }else{
                        $error[$getupload] = "Sorry seems some of the data invalid";
                    }
                }else{
                    $error = '1';
                }
            }       
            print_r($pictures);
            print_r($error);
            foreach($pictures as $urpics){
                $this->save_user_album($urpics,$this->setSession('user_id'));
            }
        }
    }


    function save_user_album($albumtitle,$session){
        $_firewall = ($this->setSession('user_id') !=="") ? $this->setSession('user_id') : "";  
            $this->jfields('album_pics_title',$albumtitle);
        //  $this->jfields('album_pics_user',$session);
        return $this->jSave('album_pics');
    }




}

任何回复都会非常感谢!!

1 个答案:

答案 0 :(得分:0)

嗨,我很抱歉,似乎我有一个解决方案,我已经保存后已经取消了... unset($this->jfields);问题已解决