| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | <head> |
|---|
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 5 | <title>Max's File Uploader Modded by ZaraByte</title> |
|---|
| 6 | <link href="style/style.css" rel="stylesheet" type="text/css" /> |
|---|
| 7 | </head> |
|---|
| 8 | |
|---|
| 9 | <body> |
|---|
| 10 | <?php |
|---|
| 11 | $myUpload = new maxUpload(); |
|---|
| 12 | //$myUpload->setUploadLocation(getcwd().DIRECTORY_SEPARATOR); |
|---|
| 13 | $myUpload->uploadFile(); |
|---|
| 14 | ?> |
|---|
| 15 | <?php |
|---|
| 16 | |
|---|
| 17 | class maxUpload{ |
|---|
| 18 | var $uploadLocation; |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | function maxUpload(){ |
|---|
| 22 | $this->uploadLocation = getcwd().DIRECTORY_SEPARATOR; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | function setUploadLocation($dir){ |
|---|
| 27 | $this->uploadLocation = $dir; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | function showUploadForm($msg='',$error=''){ |
|---|
| 31 | ?> |
|---|
| 32 | <div id="container"> |
|---|
| 33 | <div id="header"><div id="header_left"></div> |
|---|
| 34 | <div id="header_main">ZaraByte's File Uploader</div><div id="header_right"></div></div> |
|---|
| 35 | <div id="content"> |
|---|
| 36 | <?php |
|---|
| 37 | if ($msg != ''){ |
|---|
| 38 | echo '<p class="msg">'.$msg.'</p>'; |
|---|
| 39 | } else if ($error != ''){ |
|---|
| 40 | echo '<p class="emsg">'.$error.'</p>'; |
|---|
| 41 | |
|---|
| 42 | } |
|---|
| 43 | ?> |
|---|
| 44 | <form action="" method="post" enctype="multipart/form-data" > |
|---|
| 45 | <center> |
|---|
| 46 | <label>File: |
|---|
| 47 | <input name="myfile" type="file" size="30" /> |
|---|
| 48 | </label> |
|---|
| 49 | <label> |
|---|
| 50 | <input type="submit" name="submitBtn" class="sbtn" value="Upload" /> |
|---|
| 51 | </label> |
|---|
| 52 | </center> |
|---|
| 53 | </form> |
|---|
| 54 | </div> |
|---|
| 55 | |
|---|
| 56 | <?php |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | function uploadFile(){ |
|---|
| 60 | if (!isset($_POST['submitBtn'])){ |
|---|
| 61 | $this->showUploadForm(); |
|---|
| 62 | } else { |
|---|
| 63 | $msg = ''; |
|---|
| 64 | $error = ''; |
|---|
| 65 | |
|---|
| 66 | //Check destination directory |
|---|
| 67 | if (!file_exists($this->uploadLocation)){ |
|---|
| 68 | $error = "The target directory doesn't exists!"; |
|---|
| 69 | } else if (!is_writeable($this->uploadLocation)) { |
|---|
| 70 | $error = "The target directory is not writeable!"; |
|---|
| 71 | } else { |
|---|
| 72 | $target_path = $this->uploadLocation . basename( $_FILES['myfile']['name']); |
|---|
| 73 | |
|---|
| 74 | if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) { |
|---|
| 75 | $msg = basename( $_FILES['myfile']['name']). |
|---|
| 76 | " was uploaded successfully!"; |
|---|
| 77 | } else{ |
|---|
| 78 | $error = "The upload process failed!"; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | $this->showUploadForm($msg,$error); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | } |
|---|
| 88 | ?> |
|---|
| 89 | </body> |
|---|