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

// 使用现有的视频文件进行测试
$existingFile = 'd:/phpstudy_pro/WWW/yangquan_wedding/videos/opening/6a33c14d88a55.mp4';

if (!file_exists($existingFile)) {
    echo "错误: 测试文件不存在\n";
    exit(1);
}

echo "使用测试文件: $existingFile\n";
echo "文件大小: " . filesize($existingFile) . " bytes\n\n";

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

$postData = [
    'video' => new CURLFile($existingFile, 'video/mp4', 'test_upload.mp4'),
    'video_type' => 'host',
    'video_name' => '测试上传'
];

curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);

echo "HTTP状态码: $httpCode\n";
echo "CURL错误: $error\n";
echo "响应内容:\n";
echo $response . "\n";
?>