<form name="upload" method="post" action="" enctype="multipart/form-data">
Image:<input type="file" name="image">
<input type="submit" name="btnsubmit" value="Upload">
</form>
<?php
if(isset($_POST['btnsubmit'])&& $_POST['btnsubmit']= = 'Upload')
{
$image=$_FILES['image']['name'];
move_uploaded_file(['image']['tmp_name'],"uploads/".$image);
}
?>
Image:<input type="file" name="image">
<input type="submit" name="btnsubmit" value="Upload">
</form>
<?php
if(isset($_POST['btnsubmit'])&& $_POST['btnsubmit']= = 'Upload')
{
$image=$_FILES['image']['name'];
move_uploaded_file(['image']['tmp_name'],"uploads/".$image);
}
?>
- The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be uploaded
- The type="file" attribute of the <input> tag specifies that the input should be processed as a file. For example, when viewed in a browser, there will be a browse-button next to the input field.
- move_uploaded_file copies file to a folder called "uploads".
No comments:
Post a Comment