<?php
// 测试上传API是否正常工作
$url = 'http://17yqhl.cn/api/upload_video_php73.php';

// 创建一个小的测试文件（1MB）
$tmpFile = tempnam(sys_get_temp_dir(), 'test_video_');
file_put_contents($tmpFile, str_repeat('x', 1024 * 1024));

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

// 测试上传
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);

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

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

echo "正在上传到: $url\n";
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);

curl_close($ch);

echo "\nHTTP状态码: $httpCode\n";
if ($error) {
    echo "CURL错误: $error\n";
} else {
    echo "响应内容:\n";
    $responseData = json_decode($response, true);
    if ($responseData) {
        print_r($responseData);
    } else {
        echo $response;
    }
}

// 清理临时文件
unlink($tmpFile);
?>