array( 'name' => $fileInfo['basename'], 'tmp_name' => $documentPath, 'size' => filesize($documentPath), 'type' => 'audio/wav', 'from_file' => true ) ); $output = true; ob_start(); // Strangely the file path changes with a double extension copy($documentPath, $documentPath.'.wav'); $documentData = DocumentManager::upload_document( $file, $wamidir, $fileInfo['basename'], 'wav', 0, 'overwrite', false, $output ); $contents = ob_get_contents(); if (!empty($documentData)) { $newDocId = $documentData['id']; $documentData['comment'] = 'mp3'; $newMp3DocumentId = DocumentManager::addAndConvertWavToMp3( $documentData, $courseInfo, api_get_session_id(), api_get_user_id(), 'overwrite', true ); if ($newMp3DocumentId) { $newDocId = $newMp3DocumentId; } if (isset($_REQUEST['lp_item_id']) && !empty($_REQUEST['lp_item_id'])) { $lpItemId = $_REQUEST['lp_item_id']; /** @var learnpath $lp */ $lp = Session::read('oLP'); if (!empty($lp)) { $lp->set_modified_on(); $lpItem = new learnpathItem($lpItemId); $lpItem->add_audio_from_documents($newDocId); echo Display::return_message(get_lang('Updated'), 'info'); } } // Strangely the file path changes with a double extension // Remove file with one extension unlink($documentPath); } else { echo $contents; }