Skip to content

Commit 0793cae

Browse files
authored
add smalfileupload
1 parent e87b00a commit 0793cae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: disk/Onedrive.php

+14
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,20 @@ public function get_thumbnails_url($path = '/')
973973
return $thumb_url;
974974
}
975975

976+
public function smallfileupload($path, $tmpfile) {
977+
if (!$_SERVER['admin']) {
978+
$tmp1 = splitlast($tmpfile['name'], '.');
979+
if ($tmp1[0]==''||$tmp1[1]=='') $filename = md5_file($tmpfile['tmp_name']);
980+
else $filename = md5_file($tmpfile['tmp_name']) . '.' . $tmp1[1];
981+
} else {
982+
$filename = $tmpfile['name'];
983+
}
984+
$content = file_get_contents($tmpfile['tmp_name']);
985+
$result = $this->MSAPI('PUT', path_format($_SERVER['list_path'] . '/' . $path . '/' . $filename), $content);
986+
$res = $this->files_format(json_decode($result['body'], true));
987+
if (isset($res['url'])) $res['url'] = $_SERVER['host'] . path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . $filename);
988+
return output(json_encode($res, JSON_UNESCAPED_SLASHES), $result['stat']);
989+
}
976990
public function bigfileupload($path)
977991
{
978992
if ($_POST['upbigfilename']=='') return output('error: no file name', 400);

0 commit comments

Comments
 (0)