Skip to content

Commit 324b156

Browse files
committed
Update README.md
1 parent 48c051c commit 324b156

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $data = $uploader->upload($_FILES['files'], array(
2525
'onSuccess' => null, //A callback function name to be called if all files were successfully uploaded | ($files, $metas) | Callback
2626
'onUpload' => null, //A callback function name to be called if all files were successfully uploaded (must return an array) | ($file) | Callback
2727
'onComplete' => null, //A callback function name to be called when upload is complete | ($file) | Callback
28-
'onRemove' => null //A callback function name to be called by removing files (must return an array) | ($removed_files) | Callback
28+
'onRemove' => 'onFilesRemoveCallback' //A callback function name to be called by removing files (must return an array) | ($removed_files) | Callback
2929
));
3030

3131
if($data['isComplete']){
@@ -37,6 +37,18 @@ if($data['hasErrors']){
3737
$errors = $data['errors'];
3838
print_r($errors);
3939
}
40+
41+
function onFilesRemoveCallback($removed_files){
42+
foreach($removed_files as $key=>$value){
43+
$file = '../uploads/' . $value;
44+
if(file_exists($file)){
45+
unlink($file);
46+
unset($removed_files[$key]);
47+
}
48+
}
49+
50+
return $removed_files;
51+
}
4052
~~~~
4153

4254
__Download:__

0 commit comments

Comments
 (0)