Below code will do the fileuploading.
1 2 3 4 5 6 7 8 9 10 11 |
<html> <head> <title>File Uploading</title> </head> <body> <form action="fileupload.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" size="50" /> <input type="submit" value="Upload" /> </form> </body> </html> |
we have to add the below function into the fileupload.php
bool move_uploaded_file ( string $filename , string $destination );
Fileupload.php
1 2 3 4 5 6 7 8 9 10 11 |
<? if(isset($_FILES['Upload'])){ $target = "galleries/".basename($_FILES['file']['name']) ; if(move_uploaded_file($_FILES['file']['tmp_name'],$target)); } ?> |
if you want store other information related to that particular file just use the following supergloabal array
$_FILES[‘file’][‘tmp_name’]- the uploaded file in the temporary directory on the web server.
$_FILES[‘file’][‘name’] – the actual name of the uploaded file.
$_FILES[‘file’][‘size’] – the size in bytes of the uploaded file.
$_FILES[‘file’][‘type’] – the MIME type of the uploaded file.
$_FILES[‘file’][‘error’] – the error code associated with this file upload.
Note:Temporary directory name for storing files and size of the files are setting using php.ini
upload_tmp_dir
upload_max_filesize