POST https://api.weixin.qq.com/wxa/sec/vod/uploadpart?access_token=ACCESS_TOKEN
curl_init 上传一直报错"errcode" => -1
"errmsg" => "system error rid: 67c0239c-70b76efb-16684040"
使用w7corp/easywechat 提交一直这个报错 "errcode" => 47003
"errmsg" => "argument invalid! rid: 67c0255a-0ddbd90a-76984c23"
您好,没有,可参考文档指引:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/mini-drama/mini_drama.html#_1-4-%E7%94%B3%E8%AF%B7%E5%88%86%E7%89%87%E4%B8%8A%E4%BC%A0
<?php
header('Content-Type: application/json');
// 配置
$uploadDir = 'uploads/'; // 上传目录
$tempDir = $uploadDir . 'temp/'; // 临时分片目录
if (!file_exists($uploadDir)) mkdir($uploadDir, 0777, true);
if (!file_exists($tempDir)) mkdir($tempDir, 0777, true);
// 获取请求参数
$chunkIndex = isset($_POST['chunkIndex']) ? intval($_POST['chunkIndex']) : 0;
$totalChunks = isset($_POST['totalChunks']) ? intval($_POST['totalChunks']) : 1;
$fileName = isset($_POST['fileName']) ? basename($_POST['fileName']) : 'unknown_file';
// 保存分片文件
$tempFile = $tempDir . $fileName . '_part_' . $chunkIndex;
if (move_uploaded_file($_FILES['file']['tmp_name'], $tempFile)) {
// 检查是否所有分片都已上传
$allChunksUploaded = true;
for ($i = 0; $i < $totalChunks; $i++) {
if (!file_exists($tempDir . $fileName . '_part_' . $i)) {
$allChunksUploaded = false;
break;
}
}
// 如果所有分片都上传完成,则合并文件
if ($allChunksUploaded) {
$finalFile = $uploadDir . $fileName;
$out = fopen($finalFile, 'wb');
if ($out) {
for ($i = 0; $i < $totalChunks; $i++) {
$chunkFile = $tempDir . $fileName . '_part_' . $i;
$in = fopen($chunkFile, 'rb');
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
fclose($in);
unlink($chunkFile); // 删除临时分片文件
}
fclose($out);
echo json_encode(['status' => 'success', 'message' => '文件上传并合并成功']);
} else {
echo json_encode(['status' => 'error', 'message' => '合并文件失败']);
}
} else {
echo json_encode(['status' => 'success', 'message' => '分片上传成功']);
}
} else {
echo json_encode(['status' => 'error', 'message' => '分片上传失败']);
}
?>