Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <?php
- /* ignore Class Upload... */
- class Upload
- {
- public function __construct()
- {
- $width = 200;
- $height = 200;
- }
- /*public function __construct($customWidth, $customHeight)
- {
- $width = $customwidth;
- $height = $customHeight;
- }
- */
- public function makeDir($dir)
- {
- if(mkdir($dir))
- return true;
- }
- public function setDirs()
- {
- if(!is_dir("uploads"))
- {
- if(Upload::makeDir("uploads")&&Upload::makeDir("uploads/username"))
- return true;
- else
- return false;
- }
- else if(!is_dir("uploads/username"))
- {
- if(Upload::makeDir("uploads/username"))
- return true;
- else
- return false;
- }
- return true;
- }
- public function checkFiles($files)
- {
- $counter = 0;
- print_r(get_headers('http://localhost/Uploadr/uploader.php'));
- while($counter<count($files))
- {
- if(file_exists("uploads/username/".$files[$counter]))
- echo "<br/>".$files[$counter]. " already exists<br/>";
- $counter++;
- }
- }
- public function pushUpload()
- {
- if(isset($_POST['submit']))
- {
- echo "<pre>";
- print_r($_FILES);
- echo "</pre>";
- if(Upload::setDirs())
- {
- Upload::checkFiles($_FILES["docs"]["name"]);
- /*
- foreach($_FILES["docs"]["error"] as $key =>$error)
- {
- if($error == UPLOAD_ERR_OK)
- {
- $name = $_FILES["docs"]["name"][$key];
- move_uploaded_file($_FILES["docs"]["tmp_name"][$key], "uploads/username/".$_FILES["docs"]["name"][$key]);
- }
- }*/
- }
- else
- {
- echo "Cannot make necessary directories";
- return false;
- }
- }
- return true;
- }
- public function getValidation()
- {
- }
- }
- if(isset($_POST['submit']))
- if(Upload::pushUpload())
- echo "Success";
- ?>
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- var attacher= new Array();
- var fileCounter = 0;
- $('#attacher').click(function(){
- var li = document.createElement('li');
- li.setAttribute('id','file'+fileCounter);
- li.innerHTML = '<input type="file" name="docs[]" id="docs'+fileCounter+'"/>';
- document.getElementById('parentFilelist').appendChild(li);
- $('#docs'+fileCounter).click();
- fileCounter++;
- });
- });
- </script>
- <body>
- <div id="shout">
- <form method='POST' enctype='multipart/form-data' action="<?php $_SERVER['PHP_SELF'];?>">
- <input type='hidden' name='MAX_FILE_SIZE' value='2000000'/>
- <ul id='parentFilelist'></ul>
- <a href='#' id='attacher'>Attach Files</a>
- <input type='submit' name='submit' id='btn' value='Upload'/>
- </form>
- </div>
- <div id="formBox">
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement