2. Write a program to
upload and display an image using PHP.
<HTML>
<HEAD>
<TITLE>PHP PROGRAM TO UPLOAD A FILE.</TITLE>
</HEAD>
<BODY>
<FORM ACTION="fileupload.php" ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
<b>Select the Image to upload:</b>
<INPUT TYPE="file" NAME="file"><BR/>
<INPUT TYPE="Submit" VALUE="Upload" NAME="Upload"> <BR/>
</FORM>
<?php
if(isset($_POST['Upload']))
{
$path = "photos/" . $_FILES["file"]["name"];
if(move_uploaded_file($_FILES["file"]["tmp_name"], $path))
{
echo "<img src=",$path," height=250 width=500 >";
}
else
{
echo "Error!";
}
}
?>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>PHP PROGRAM TO UPLOAD A FILE.</TITLE>
</HEAD>
<BODY>
<FORM ACTION="fileupload.php" ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
<b>Select the Image to upload:</b>
<INPUT TYPE="file" NAME="file"><BR/>
<INPUT TYPE="Submit" VALUE="Upload" NAME="Upload"> <BR/>
</FORM>
<?php
if(isset($_POST['Upload']))
{
$path = "photos/" . $_FILES["file"]["name"];
if(move_uploaded_file($_FILES["file"]["tmp_name"], $path))
{
echo "<img src=",$path," height=250 width=500 >";
}
else
{
echo "Error!";
}
}
?>
</BODY>
</HTML>
No comments :
Post a Comment