Public paste
File-Upload
By: Xmoo | Date: May 13 2009 12:48 | Format: PHP | Expires: never | Size: 3.04 KB | Hits: 553

  1. <?php
  2. $user = $_SESSION['username'];
  3. $location = "files/".$user."/";
  4.  
  5. echo "<font class='kop'>File Upload</font><br><br>";
  6. if(!empty($_POST)){
  7.    if(is_uploaded_file($_FILES['upload']['tmp_name']))
  8.    {  
  9.         if($_FILES['afbeelding']['size']>64000)
  10.                    {
  11.         echo "<img src='images/pointers/delete.png' alt='ERROR' border='0'> <b>File to BIG! (Max 500kb allowed)</b>";
  12.                    exit;
  13.                    }
  14.         if(!eregi("((.jpg|.JPG|.gif|.GIF|.jpeg|.JEPG|.png|.PNG)$)", $_FILES['upload']['name']))
  15.                    {
  16.         echo "<img src='images/pointers/delete.png' alt='ERROR' border='0'> <b>Wrong extension! (JPG, GIF & PNG allowed!)</b>";
  17.                    exit;
  18.                    }
  19.         if(!move_uploaded_file($_FILES['upload']['tmp_name'],
  20.                                $location.$_FILES['upload']['name']))
  21.                   {
  22.         echo"<img src='images/pointers/delete.png' alt='ERROR' border='0'> <b>File could not move!</b>";
  23.                   exit;
  24.                   }
  25. echo "<br><img src='images/pointers/view.png' alt='SUCCES' border='0'> <b>The File: <a href='http://www.url.org/files/".$user."/".$_FILES['upload']['name']."' target='_blank'>".$_FILES['upload']['name']."</a> Has Been Uploaded!</b>
  26. <br><br><br>
  27. <b>URL:</b><br>
  28. <input type='text' name='url' size='59' onclick='javascript:url.focus();url.select();' value='http://www.url.org/files/".$user."/".$_FILES['upload']['name']."'' READONLY/>
  29. <br><br>
  30. <b>Link:</b><br>
  31. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  32. [url]http://www.url.org/files/".$user."/".$_FILES['upload']['name']."[/url]</textarea>
  33. <br><br>
  34. <b>Link with title:</b><br>
  35. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  36. [url=http://www.url.org/files/".$user."/".$_FILES['upload']['name']."]".$_FILES['upload']['name']."[/url]</textarea>
  37. <br><br>      
  38. <b>Image:</b><br>
  39. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  40. [img]http://www.url.org/files/".$user."/".$_FILES['upload']['name']."[/img]</textarea>
  41. <br><br>    
  42. <b>Thumbnail:</b><br>
  43. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  44. [thumb]http://www.xmoo.org/mytrainer/files/".$user."/".$_FILES['upload']['name']."[/thumb]</textarea>
  45. <br><br>    
  46. <b>Image link:</b><br>
  47. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  48. [link]http://www.url.org/files/".$user."/".$_FILES['upload']['name']."[/link]</textarea>";
  49.    } else {
  50.    echo "<img src='images/pointers/delete.png' alt='ERROR' border='0'> <b>The Upload has failed!</b>"; }
  51. } else {
  52. echo '<center><form method="post" action="" enctype="multipart/form-data">
  53.     <b>File:</b> <input type="file" name="upload" size="50" /><br/> <br/>
  54.     <input type="submit" name="submit" value="Upload!" /></form></center>';
  55. }
  56. ?>