PHPを使用してサーバーにファイルをアップロードしようとしていますが、いくつか問題があります。私はこのガイドを見つけました:http://www.sumedh.info/articles/store-upload-image-postgres-php-2.html。 私のHTMLは次のとおりです。imgファイルをPHPでアップロードするには
<form action="img_user.php" method="POST" enctype="multipart/form-data" >
<button id="buttonImgProf" class="btn" type="button" onclick="caricaImgProf()">Inserisci un immagine</button>
<div id="imgProfLoader" class="postContent" style="display:none;">
Name : <input type="text" name="name" size="25" length="25" value="">
<input type="file" name="userfile"></input>
<button class="btn" type="submit">Carica immagine</button>
</div>
</form>
(私はJavaScriptを使用しているため、部品が表示されません)。 PHPのコードは次のとおりです。
$uploaddir = 'localhost'; //i have try lots of dir, maybe the error is here?
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$name = $_POST['name'];
echo $_FILES['userfile']['tmp_name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{ echo "File is valid, and was successfully uploaded.\n";
}
else { echo "File not uploaded"; }
出力はFile not uploaded
は、あなたが答えに投稿されたものにあなたの質問のコードを上書きしないでください。 ** edit:** ....私が試したもの " –