<?php
if(isset($_POST['pic'])){
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 300000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
}
echo "<h1>Done! Looks Great!</h1>";
}
}
else
{
echo "Invalid file";
}
}
?>
<form action="editprofile.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
<p>Image format should be png or jpg.</p>
<center><p class="submit"><input type="submit" name="pic" value="Upload Picture" /></p></center>
</form>
</div>
<p style="text-align:center; font-size:18px;">Current Picture</p>
<?php
$filename = $_FILES['file']['tmp_name'];
?>
<img src="/path/to/the/upload/folder/<?php echo $filename; ?>"/>
<img src="../../upload/foto.PNG" class="picture"/>
정의되지 않은 색인 파일과 같은 오류가 발생합니다.서버에서 파일을 가져 오는 중에 오류가 발생했습니다.
오류는 마지막 몇 줄에 있습니다.
기본적으로 이미지가있는 폴더가 있습니다. 폴더에 유일한 이미지를 표시하고 싶습니다.
프로필 사진과 비슷합니다. – brad
마지막 9 행은 마지막 행을 제외하고는 의미가 없습니다. 로컬 파일 경로를 사용하여 작동하지 않는 이미지를 표시하고 있습니다. 그걸 제거하면 이미 괜찮을 수도 있습니다. –