我正在尝试在本地Firebase中使用php。但是,当我单击按钮时,我的php脚本已下载。这是我的代码
<div id="popover-head" class="hide">
Unggah berkas disini
</div>
<div id="popover-content" class="hide">
<form action="save.php" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="upload" value="Upload">
</form>
</div>
这是我的php文件
<?php
if($_POST['upload']){
$ekstensi_diperbolehkan = array('png','jpg');
$nama = $_FILES['file']['name'];
$x = explode('.', $nama);
$ekstensi = strtolower(end($x));
$ukuran = $_FILES['file']['size'];
$file_tmp = $_FILES['file']['tmp_name'];
if(in_array($ekstensi, $ekstensi_diperbolehkan) === true){
if($ukuran < 1044070){
$ngupload = move_uploaded_file($file_tmp, 'src/FileUpload/'.$nama);
if($ngupload){
echo "<script type='text/javascript'>alert('Berhasil Mengunggah');</script>";
}else{
echo "<script type='text/javascript'>alert('Gagal Mengunggah');</script>";
}
}else{
echo "<script type='text/javascript'>alert('Ukuran File terlalu besar');</script>";
}
}else{
echo "<script type='text/javascript'>alert('Ekstensi File Tidak Diperbolehkan');</script>";
}
}
?>