Frage

I'm working right now on an upload script which tags my data with ID3 tags. At this point right now, I can upload small files 3MB to 10MB but if I want to upload files bigger like 85M, it doesn't work anymore and it returns me empty arrays

Array () Array ()

On the other side, I configured my php runtime to allow uploads up to 150M. Below is my code

<?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');
}
?>

I don't know what could be wrong.. Any help appreciated

War es hilfreich?

Lösung

Sounds like you forgot to increase post_max_size, increasing upload_max_filesize is usually not enough since the post_max_size defaults are usually relatively small too.

http://www.php.net/manual/en/ini.core.php#ini.post-max-size

When uploading a file larger than this limit, then $_POST and $_FILES will be empty.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top