検索

ホームページ  >  に質問  >  本文

重複した質問: フォームを使用してフォルダーにファイルをアップロードできません

<p>admin.php:</p> <pre class="brush:php;toolbar:false;"><!DOCTYPE html> <html lang="ja"> <頭> <メタ文字セット="UTF-8"> <meta name="viewport" content="width=device-width、initial-scale=1.0"> <title>管理者</title> </head> <本体> <form action="upload.php" method="POST" enctype="multipart/form-data"> 画像: <input type="file" name="image"> <br> 販売またはレンタル: <input type="text" name="isForSale"> <br> 価格: <input type="text" name="price"> <br> 場所: <input type="text" name="location"> <br> エリア: <input type="text" name="エリア"> <br> 寝室: <input type="text" name="寝室"> <br> <button type="submit">アップロード</button> </フォーム> </ボディ> </html></pre> <p>upload.php:</p> <pre class="brush:php;toolbar:false;"><?php if(isset($_POST['submit'])) { $file = $_FILES['画像']; $fileName = $_FILES['画像']['名前']; $fileTmpName = $_FILES['画像']['tmp_name']; $fileSize = $_FILES['画像']['サイズ']; $fileError = $_FILES['画像']['エラー']; $fileType = $_FILES['画像']['タイプ']; $fileExt =explode('.',$fileName); $fileActExt = strto lower(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("場所: admin.php?uploadsuccess"); } それ以外 { echo "ファイルのアップロード中にエラーが発生しました"; } } それ以外 { echo "この種類のファイルはアップロードできません。(jpg、jpeg、png のみ)"; } } ?></pre> <p>現在、画像をネットワークに転送し、ファイル内に保存していますが、これは機能しません。空白のページ (upload.php) に移動するだけです。 Ubuntu は非常に新しいため、どのように修正できるかはわかりません。
P粉764785924P粉764785924544日前581

全員に返信(1)返信します

  • P粉530519234

    P粉5305192342023-08-09 18:59:02

    Your submit button should contain the name attribute with the submit value:

    <button type="submit" name="submit">Upload</button>

    返事
    0
  • キャンセル返事