1 回答

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超6個(gè)贊
為我實(shí)現(xiàn)和正常工作的代碼。其邏輯很簡(jiǎn)單,它接收文件并將其移動(dòng)到服務(wù)器,移動(dòng)后將其加載到 firebase 存儲(chǔ)。
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$name = $_FILES['uploadedfile']['name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$myfile = fopen($target_path, "r") ;
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded";
$this->bucket->upload($myfile, [
'name' => $_POST["proyecto"] . "/" . $name
]);
} else{
echo "There was an error uploading the file, please try again!";
}
- 1 回答
- 0 關(guān)注
- 154 瀏覽
添加回答
舉報(bào)