This is one more feature of Html <Form> tag for
uploading files or images using PHP Programming. Many times we have to handle
uploading image by this feature. $_FILES only use for uploading file online in
PHP Programming. We can store each file as multidimensional array in the
$_FILES Super global array in PHP Script. All you need to do to upload a file
from a form is choose a special type encoding called multipart-data and your
browser will handle the rest. $_FILES always use like multidimensional array in
<Form>tag. Each key access the first field name and second field name
contain desired name of images. We can use this key for accessing information
about file in file information.
1. $FILES
[‘file’][‘name’] - The name of uploading
file .
2. $FILES
[‘file’][‘type’] - The content type of uploading file .
3. $FILES
[‘file’][‘size’] - The size of file in
byte .
4. $FILES
[‘file’][‘tmp_name’] - The name of
temporary file store on the server.
5. $FILES
[‘file’][error’] - The error code
resulting from uploading file .
Add caption |
Program of Image Uploading
First file create
<html>
<body>
<title>PHP Form Upload</title></head>
<form method='post' action='upload.php'
enctype='multipart/form-data'>
Select File: <input type='file' name='filename' size='10'
/>
<input type='submit' value='Upload' />
</form>
</body>
</html>
Second file given name upload.php
<html>
<body>
<?php
if ($_FILES)
{
$name = $_FILES['filename']['name'];
move_uploaded_file($_FILES['filename']['tmp_name'], $name);
echo "Uploaded image '$name'<br /><img
src='$name' />";
}
echo "</body></html>";
?>
</body>
</html>Here Video Tutorial