העלאת קובץ גדול לא עובד
-
יש לי קוד שאמור להצליח לעלות גם קבצים גדולים ומשום מה בשלב של החיבור זה נתקע
מצורף הקוד והפלט אשמח לעזרה @שמואל<?php // פרטי התחברות והגדרות $token = ':'; // מספר מערכת וסיסמה או API_KEY $localFilePath = 'file.mp3'; // הקובץ שברצונך להעלות $remotePath = 'ivr2:567.wav'; // הנתיב במערכת $chunkSize = 10 * 1024 * 1024; // גודל מקטע (10MB לדוגמה) $fileName = basename($localFilePath); $totalFileSize = filesize($localFilePath); $qquuid = bin2hex(random_bytes(16)); $totalParts = ceil($totalFileSize / $chunkSize); $handle = fopen($localFilePath, 'rb'); if (!$handle) { die("Cannot open local file"); } for ($partIndex = 0; $partIndex < $totalParts; $partIndex++) { $offset = $partIndex * $chunkSize; fseek($handle, $offset); $chunkData = fread($handle, $chunkSize); // שמירת החלק כקובץ זמני $tmpFile = tempnam(sys_get_temp_dir(), 'chunk_'); file_put_contents($tmpFile, $chunkData); $postFields = [ 'token' => $token, 'path' => $remotePath, 'qquuid' => $qquuid, 'qqpartindex' => $partIndex, 'qqpartbyteoffset' => $offset, 'qqchunksize' => strlen($chunkData), 'qqtotalparts' => $totalParts, 'qqtotalfilesize' => $totalFileSize, 'qqfilename' => $fileName, 'qqfile' => curl_file_create($tmpFile, 'application/octet-stream', 'part') ]; $ch = curl_init('https://www.call2all.co.il/ym/api/UploadFile'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if ($response === false) { echo "Curl error on part $partIndex: " . curl_error($ch) . "\n"; } else { echo "Part $partIndex uploaded: $response\n"; } curl_close($ch); unlink($tmpFile); // מחיקת הקובץ הזמני } fclose($handle); // שליחת בקשת Done $doneParams = [ 'done' => '', 'token' => $token, 'path' => $remotePath, 'qquuid' => $qquuid, 'qqfilename' => $fileName, 'qqtotalfilesize' => $totalFileSize, 'qqtotalparts' => $totalParts, 'convertAudio' => 1 ]; $doneUrl = 'https://www.call2all.co.il/ym/api/UploadFile?' . http_build_query($doneParams); $response = file_get_contents($doneUrl); if ($response === false) { echo "Error sending Done request\n"; } else { echo "Done response: $response\n"; } ?>וזה הפלט
Part 0 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 1 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 2 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 3 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 4 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 5 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 6 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 7 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 8 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 9 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 10 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 11 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 12 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 13 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 14 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 15 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 16 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 17 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 18 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 19 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 20 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 21 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":10485760,"yemotAPIVersion":7,"success":true} Part 22 uploaded: {"responseStatus":"OK","path":"ivr/567.wav","size":785716,"yemotAPIVersion":7,"success":true} Done response: {"responseStatus":"ERROR","message":"System error","messageCode":105,"yemotAPIVersion":7,"success":false}
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות