【发布时间】:2013-08-08 16:24:28
【问题描述】:
我现在正在编写一个上传脚本,该脚本使用 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');
}
?>
我不知道可能出了什么问题.. 任何帮助表示赞赏
【问题讨论】:
-
您假设上传成功。
var_dump($_FILES['files']['error'])节目是什么?永远不要永远假设成功。始终检查失败并将成功视为惊喜。
标签: php debugging size filesize