Soalan pendua: Tidak dapat memuat naik fail ke folder menggunakan borang
P粉764785924
P粉764785924 2023-08-08 21:57:36
0
1
521
<p>admin.php:</p> <pre class="brush:php;toolbar:false;"><!DOCTYPE html> <html lang="en"> <kepala> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Pentadbir</title> </head> <badan> <form action="upload.php" method="POST" enctype="multipart/form-data"> Imej: <input type="file" name="image"> <br> Jualan atau Sewa: <input type="text" name="isForSale"> <br> Harga: <input type="text" name="price"> <br> Lokasi: <input type="text" name="location"> <br> Kawasan: <input type="text" name="area"> <br> Bilik tidur: <input type="text" name="bedrooms"> <br> <button type="submit">Muat naik</button> </form> </badan> </html></pre> <p>upload.php:</p> <pre class="brush:php;toolbar:false;"><?php if(isset($_POST['submit'])) { $fail = $_FILES['imej']; $fileName = $_FILES['imej']['nama']; $fileTmpName = $_FILES['imej']['tmp_name']; $fileSize = $_FILES['imej']['saiz']; $fileError = $_FILES['imej']['ralat']; $fileType = $_FILES['imej']['jenis']; $fileExt = explode('.',$fileName); $fileActExt = strtolower(end($fileExt)); $allow = array('jpg','jpeg','png'); if(in_array($fileActExt,$allow)) { if($fileError === 0) { $fileNewName = uniqid('', true).".".$fileActExt; $fileDestination = 'FamilyRealEstate/FamilyRealEstateImages/uploads'.$fileNewName; move_uploaded_file($fileTmpName, $fileDestination); header("Lokasi: admin.php?uploadsuccess"); } lain { echo "Ralat memuat naik fail anda"; } } lain { echo "Anda tidak boleh memuat naik fail jenis ini.(Hanya jpg, jpeg, png)"; } } ?></pra> <p>我正在尝试将图片上传到网络并在文件夹中保存它。这似乎不起作守玪。面(upload.php)。可能是因为文件夹的权限,然而我正在使用Ubuntu,并且非常新,所以我真的不知道如何修复它。</p>
P粉764785924
P粉764785924

membalas semua(1)
P粉530519234

Butang hantar anda harus mengandungi atribut nama dengan nilai hantar:

<button type="submit" name="submit">Upload</button>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan