上载文件的PHP Id3tag更改

上载文件的PHP Id3tag更改,php,linux,id3-tag,Php,Linux,Id3 Tag,有一个lib getid3可以写入/读取id3标记。这是我的上传脚本: // Validate the files to be uploaded if(empty($error)) { $tpath = __DIR__ .'/../uploads/tracks/'; $mpath = __DIR__ .'/../uploads/media/'; if($type) { if(isset($_FILES['track

有一个lib getid3可以写入/读取id3标记。这是我的上传脚本:

// Validate the files to be uploaded
    if(empty($error)) {
        $tpath = __DIR__ .'/../uploads/tracks/';
        $mpath = __DIR__ .'/../uploads/media/';

        if($type) {
            if(isset($_FILES['track']['name'])) {
                // Get the total uploaded size
                $query = $this->db->query(sprintf("SELECT (SELECT SUM(`size`) FROM `tracks` WHERE `uid` = '%s') as upload_size", $this->db->real_escape_string($this->id)));
                $result = $query->fetch_assoc();

                $ext = pathinfo($_FILES['track']['name'][$num], PATHINFO_EXTENSION);
                $size = $_FILES['track']['size'][$num];
                $fullname = $_FILES['track']['name'][$num];
                $allowedExt = explode(',', $this->track_format);
                $maxsize = $this->track_size;

                // Validate the total upload size allowed
                if(($result['upload_size'] + $size) > $this->track_size_total) {
                    $error[] = array(0, saniscape($values['title']));
                }

                // Get file type validation
                $track = validateFile($_FILES['track']['tmp_name'][$num], $_FILES['track']['name'][$num], $allowedExt, 1);

                if($track['valid'] && $size < $maxsize && $size > 0) {
                    $t_tmp_name = $_FILES['track']['tmp_name'][$num];
                    $name = pathinfo($_FILES['track']['name'][$num], PATHINFO_FILENAME);
                    $size = $_FILES['track']['size'][$num];
                    $tName = mt_rand().'_'.mt_rand().'_'.mt_rand().'.'.$this->db->real_escape_string($ext);



                    // Send the track name in array format to the function
                    $values['name'] = $tName;
                    $values['size'] = $size;

                    $t_upload = true;
                } elseif($_FILES['track']['name'][$num] == '') {
                    // If the file size is higher than allowed or 0
                    $error[] = array(1);
                }
                if(!empty($ext) && ($size > $maxsize || $size == 0)) {
                    // If the file size is higher than allowed or 0
                    $error[] = array(2, saniscape($values['title']), fsize($maxsize));
                }
                if(!empty($ext) && !$track['valid']) {
                    // If the file format is not allowed
                    $error[] = array(3, saniscape($values['title']), implode(', ', $allowedExt));
                }
            }
        }

        if(empty($GLOBALS['multiart'])) {
            if(isset($_FILES['art']['name'])) {
                foreach($_FILES['art']['error'] as $key => $err) {
                    $ext = pathinfo($_FILES['art']['name'][$key], PATHINFO_EXTENSION);
                    $size = $_FILES['art']['size'][$key];
                    $allowedExt = explode(',', $this->art_format);
                    $maxsize = $this->art_size;

                    // Get file type validation
                    $image = validateFile($_FILES['art']['tmp_name'][$key], $_FILES['art']['name'][$key], $allowedExt, 0);

                    if($image['valid'] && $size < $maxsize && $size > 0 && !empty($image['width']) && !empty($image['height'])) {
                        $m_tmp_name = $_FILES['art']['tmp_name'][$key];
                        $name = pathinfo($_FILES['art']['name'][$key], PATHINFO_FILENAME);
                        $fullname = $_FILES['art']['name'][$key];
                        $size = $_FILES['art']['size'][$key];

                        // If there's no error during the track's upload
                        if(empty($error)) {
                            // Generate the file name & store it into a super global to check when multi upload
                            $mName = $GLOBALS['multiart'] = mt_rand().'_'.mt_rand().'_'.mt_rand().'.'.$this->db->real_escape_string($ext);
                        }

                        // Delete the old image when editing the track
                        if(!$type) {
                            $query = $this->db->query(sprintf("SELECT `art` FROM `tracks` WHERE `id` = '%s'", $this->db->real_escape_string($_GET['id'])));
                            $result = $query->fetch_assoc();
                            deleteImages(array($result['art']), 2);
                        }

                        // Send the image name in array format to the function
                        $values['art'] = $mName;

                        $m_upload = true;
                    } elseif($_FILES['art']['name'][$key] == '') {
                        // If no file is selected
                        if($type) {
                            $values['art'] = 'nocover6.jpg';
                        } else {
                            // If the cover artwork is not selected, unset the image so that it doesn't update the current one
                            unset($values['art']);
                        }
                    }
                    if(!empty($ext) && ($size > $maxsize || $size == 0)) {
                        // If the file size is higher than allowed or 0
                        $error[] = array(4, fsize($maxsize));
                    }
                    if(!empty($ext) && !$image['valid']) {
                        // If the file format is not allowed
                        $error[] = array(5, implode(', ', $allowedExt));
                    }
                }
            }
        } else {
            // Generate a new file name
            $ext = pathinfo($GLOBALS['multiart'], PATHINFO_EXTENSION);
            $finalName = mt_rand().'_'.mt_rand().'_'.mt_rand().'.'.$this->db->real_escape_string($ext);
            // Copy the previous track image
            copy($mpath.$GLOBALS['multiart'], $mpath.$finalName);
            // Store the new file name
            $values['art'] = $finalName;
        }
    }

    if(!empty($error)) {
        return array(0, $error);
    } else {
        if($t_upload) {
            // Move the file into the uploaded folder
            move_uploaded_file($t_tmp_name, $tpath.$tName);

        } 
        if($m_upload) {
            // Move the file into the uploaded folder
            move_uploaded_file($m_tmp_name, $mpath.$mName);
        }
        return array(1, $values);
    }

}
我的上传脚本不起作用,我不能上传任何音乐或其他东西。我应该把id3编写脚本放在哪里?以下是id3write的脚本:

                $TextEncoding = 'UTF-8';
                $getID3 = new getID3;
                $getID3->setOption(array('encoding'=>$TextEncoding));
                $tagwriter = new getid3_writetags;
                $tagwriter->filename = $tpath.$tname;
                $tagwriter->tagformats = array('id3v2.3');
                $tagwriter->overwrite_tags = true;
                $tagwriter->remove_other_tags = true;
                $tagwriter->tag_encoding = $TextEncoding;
                $TagData = array(
                'album'         => array('Album'),
                'comment'       => array('Text'),
                'track'         => array('2ndtext'),);
                $tagwriter->tag_data = $TagData;

请帮助:)

您需要的部分在哪里?另外,您应该尽可能多地删掉这个脚本,直到您可以创建一个。很抱歉,我有1个文件classes.php,其中包含所有classess和func。在文件write.php的开头也提出了要求。没有效果。但是如果我在返回数组(1,$value)之后更改了上传函数末尾的getid3脚本的位置;上传工作,但脚本似乎并没有真正改变id3标签。我认为它将改变脚本运行的位置,但我找不到它在哪里。
                $TextEncoding = 'UTF-8';
                $getID3 = new getID3;
                $getID3->setOption(array('encoding'=>$TextEncoding));
                $tagwriter = new getid3_writetags;
                $tagwriter->filename = $tpath.$tname;
                $tagwriter->tagformats = array('id3v2.3');
                $tagwriter->overwrite_tags = true;
                $tagwriter->remove_other_tags = true;
                $tagwriter->tag_encoding = $TextEncoding;
                $TagData = array(
                'album'         => array('Album'),
                'comment'       => array('Text'),
                'track'         => array('2ndtext'),);
                $tagwriter->tag_data = $TagData;