<!DOCTYPE html>
 
<html lang="en">
 
    <head>
 
        <meta charset="utf-8">
 
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
 
        <meta name="viewport" content="width=device-width, initial-scale=1">
 
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
 
        <title>Uploader Class Example</title>
 
 
        <!-- Bootstrap -->
 
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
 
 
        <!--[if lt IE 9]>
 
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
 
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
 
        <![endif]-->
 
    </head>
 
    <body>
 
        <div class="container-fluid">
 
            <div class="row">
 
                <div class="col-xs-8 col-xs-offset-2">
 
                    <?php
 
                    require 'class.UploaderException.php';
 
                    require 'class.Uploader.php';
 
                    try {
 
                        $file = new Uploader($_FILES["myfile"], "images/");
 
                        $name = $file->setMaxSize(3)
 
                                ->setAllowedExtensions(array(".doc",".docx"))
 
                                ->renameIfExists()
 
                                ->upload()
 
                                ->getUploadedFileName();
 
                        echo "<div class='alert alert-success'>File Uploaded ($name)</div>";
 
                    } catch (UploaderException $e) {
 
                        echo "<div class='alert alert-danger'>".$e->getMessage()."</div>";
 
                    }
 
                    ?>
 
                    <form method="post" action="index.php" enctype="multipart/form-data">
 
                        <div class="form-group">
 
                            <label>File:</label>
 
                            <input type="file" name="myfile" class="form-control" />
 
                        </div>
 
                        <input type="submit" name="upload" value="Upload" class="btn btn-primary" />
 
                    </form>
 
                </div>
 
            </div>
 
        </div>
 
 
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
 
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
 
        <!-- Include all compiled plugins (below), or include individual files as needed -->
 
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
 
    </body>
 
</html>
 
 |