-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Hello,
When using chunks, the final file is recomposed from chunk files.
This procedure takes a lot of time: takes as much as you were copying the file intro another file (on se same disk). Consider a copy of 10GB file, thats too much.
I've changed the class, using the example from here
https://github.com/moxiecode/plupload/blob/master/examples/upload.php
loose "write_file_to" and "write_chunks_to_file" functions
and leave only
$file_path = rtrim($conf['target_dir'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file_name;
// Open temp file
if (!$out = @fopen("{$file_path}.part", $conf['chunks'] ? "ab" : "wb")) {
throw new Exception('', PLUPLOAD_OUTPUT_ERR);
}
if (!empty($_FILES)) {
if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
throw new Exception('', PLUPLOAD_MOVE_ERR);
}
// Read binary input stream and append it to temp file
if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {
throw new Exception('', PLUPLOAD_INPUT_ERR);
}
}
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
@fclose($out);
@fclose($in);
// Check if file has been uploaded
if (!$conf['chunks'] || $conf['chunk'] == $conf['chunks'] - 1) {
// Strip the temp .part suffix off
rename("{$file_path}.part", $file_path);
}
return array(
'name' => $file_name,
'path' => $file_path,
//'size' => filesize($file_path)
);thank you.
Metadata
Metadata
Assignees
Labels
No labels