function createFileFromChunks($temp_dir, $file, $chunkSize)
// check that all the parts are present // the size of the last part is between chunkSize and 2*$chunkSize if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) {
// create the final destination file if (($fp = fopen('/temp/'.$vbulletin->userinfo['username'].'/'.$fileName, 'w')) !== false) { for ($i=1; $i<=$total_files;) } fclose($fp); } else { _log('cannot create the destination file'); return false; }
// rename the temporary directory (to avoid access from other // concurrent chunks uploads) and than delete it if (rename($temp_dir, $temp_dir.'_UNUSED')) { rrmdir($temp_dir.'_UNUSED'); } else { rrmdir($temp_dir); } }
}
the code
PHP Code:
if (!empty($_FILES)) foreach ($_FILES as $file) {
// check the error status if ($file['error'] != 0) { _log('error '.$file['error'].' in file '.$_POST['resumableFilename']); continue; }
// init the destination file (format <filename.ext>.part<#chunk> // the file is stored in a temporary directory $temp_dir = '/temp/'.$vbulletin->userinfo['username'].'/'.$_POST['resumableIdentifier']; $dest_file = $temp_dir.'/'.$_POST['resumableFilename'].'.part'.$_POST['resumableChunkNumber':