<?php
echo "测试上传API修复...\n\n";

// 创建一个较大的测试文件（10MB）
$tmpFile = tempnam(sys_get_temp_dir(), 'test_video_');
$fileSize = 10 * 1024 * 1024; // 10MB
$chunk = str_repeat('x', 1024 * 1024); // 1MB chunk
for ($i = 0; $i < 10; $i++) {
    file_put_contents($tmpFile, $chunk, FILE_APPEND);
}

echo "创建测试文件: $tmpFile (" . filesize($tmpFile) / 1024 / 1024 . "MB)\n\n";

// 测试上传
$url = 'http://localhost/yangquan_wedding/api/api_router.php?path=video/upload';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);

$postData = [
    'video' => new CURLFile($tmpFile, 'video/mp4', 'test_large.mp4'),
    'video_type' => 'host',
    'video_name' => '测试大文件'
];

curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "HTTP状态码: $httpCode\n";
echo "响应内容:\n";
echo $response . "\n";

// 清理
unlink($tmpFile);

// 检查服务器配置
echo "\n\n--- 服务器配置检查 ---\n";
$ch = curl_init('http://localhost/yangquan_wedding/check_php_config.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
?>