Hello World!

Upload a File

get_error_message(); }else{ echo "File upload successful!"; test_convert($uploaded); } } } function test_convert($id) { // Get the file and post details $file = get_attached_file($id); $post = get_post($id); // Set the endpoint for the online converter $endpoint = "https://cloud.idrsolutions.com/cloud/" . IDRCloudClient::INPUT_BUILDVU; $filePath = realpath($file); $fileName = pathinfo($filePath, PATHINFO_FILENAME); // Get the filename without extension // This is where the output will be written to $outputdir = preg_replace("[\\/]", DIRECTORY_SEPARATOR, plugin_dir_path(__FILE__)) . "output" . DIRECTORY_SEPARATOR . $fileName . DIRECTORY_SEPARATOR; // Create the directory if it doesn't exist if (!file_exists($outputdir)) { mkdir($outputdir, 0777, true); } $conversion_params = array( 'token' => $your_token, 'input' => IDRCloudClient::INPUT_UPLOAD, 'file' => $filePath ); $results = IDRCloudClient::convert(array( 'endpoint' => $endpoint, 'parameters' => $conversion_params )); // This method is very important as it allows us access to the file system WP_Filesystem(); IDRCloudClient::downloadOutput($results, $outputdir); $downloadUrl = $results['downloadUrl']; $basename = pathinfo($downloadUrl, PATHINFO_BASENAME); // Unzip the file $result = unzip_file($outputdir . $basename, $outputdir); }