文件上载在调试时返回空数组


File upload returns empty array while debugging

我现在正在编写一个上传脚本,该脚本使用ID3标记标记我的数据。现在,我可以上传3MB到10MB的小文件,但如果我想上传85M这样大的文件,它就不能再工作了,它会给我返回空数组

Array () Array ()

另一方面,我将php运行时配置为允许上传高达150M的文件。下面是我的代码

<?php
// Starting session
session_start();
error_reporting(E_ALL);
//// loading configuration
require_once '../lib/config.php';
require_once '../vendor/autoload.php';
print_r($_POST);
print_r($_FILES);
if ((isset($_POST)) && (!isset($_SESSION['AIRTIME_3RDPARTY_UPLOADER']))) {
    // Post variables
    $date = $_POST['date'];
    $show = $_POST['show'];
    $presenter = $_POST['presenter'];
    $desc = $_POST['description'];
    $file = $_FILES['files'];

    date_default_timezone_set('Europe/Berlin');

// config for file handling (where to put)
    $upload_dir = $config['airtime']['upload'];
    $baseFilename = basename($file['name']);
    $explodeName = explode(".", $baseFilename);
    $newName = $explodeName[0] . "-" . date('dMY') . "-" . uniqid();
    $finalName = $newName . "." . $explodeName[1];
    $upload = $upload_dir . $finalName;
    $getFileSize = ($file['size'] / 1024) / 1024;

    if ($getFileSize > $config['airtime']['upload_size']) {
       print('Your file is to big for this system');
    }
// only allowing the filetpyes within the array
    $allowed_filtypes = array('audio/mp3', 'audio/ogg', 'audio/vnd.wave', 'audio/mp4');
// Check if there is any error with uploading the file
    if ($file["error"] > 0) {
        print_r($file);
    } else {
        if (in_array($file['type'], $allowed_filtypes)) {
// Initialize getID3 tag-writing module
            $tagwriter = new getid3_writetags();
//$tagwriter->filename = '/path/to/file.mp3';
            $tagwriter->filename = $file['tmp_name'];
            $tagwriter->tagformats = array('id3v1', 'id3v2.3');
// set various options (optional)
            $tagwriter->overwrite_tags = true;
            $tagwriter->tag_encoding = $TaggingFormat;
            $tagwriter->remove_other_tags = true;
// Populating Data Array
            $TagData = array(
                'title' => array($show . "-" . $date),
                'artist' => array($presenter),
                'year' => array(date('Y')),
                'genre' => array('Radioshow'),
                'comment' => array($desc)
            );
// assigning Data to Variable
            $tagwriter->tag_data = $TagData;
// write tags
            $tagwriter->WriteTags();
// Moving file to repo 
            move_uploaded_file($file['tmp_name'], $upload);
//header 
            header('Location: submit_success.php');
        } else {
            header('Location: submit_fail.php');
        }
    }
} else {
   print('Wrong form key');
}
?>

我不知道出了什么问题。。感谢的任何帮助

听起来你忘记增加post_max_size了,增加upload_max_filesize通常是不够的,因为post_max_size的默认值通常也相对较小。

http://www.php.net/manual/en/ini.core.php#ini.post-最大尺寸

上传大于此限制的文件时,$_POST$_FILES将为空。