Whenever you create a website then there is need to
dynamicity. If your sites only provides the information for the then it’s only
the informational site. Such type of sites only used for the one way from that
sites you can provide the information but you can’t get the user responses. For
adding the dynamicity use form in the website. With the help of form user can
send the data to the server.
There is providing the code from which upload the picture document
or you use this code according to your requirement.
Step 1: First of create the file upload.php
In this file we write the code for uploading
the picture in html format. This is as
given
below.
<form
method="post" action="<?php ?>"
enctype="multipart/form-data">
<input type="file"
name="file" />
<input type="submit"
name="send" value="send" />
</form>
Step 2: Now need to add php code so that wen you
take the action it work out.
<?php
if(isset($_POST['send']))
{
if(($_FILES["file"]["type"]=="image/jpeg")||
($_FILES["file"]["type"]=="image/png") ||
($_FILES["file"]["type"]=="image/jpg")&&($_FILES["file"]["size"]<1024))
{
if($_FILES["file"]["error"]>0)
{
echo
$_FILES["file"]["error"];
}
else
{
if(file_exists("upload/".$_FILES["file"]["name"]))
{
echo
"File already present";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$_FILES["file"]["name"]);
echo "File is uploaded";
}
}
}
else
{
echo "File not a
valid";
}
}
?>
No comments:
Post a Comment