Public paste
File
By: Xmoo | Date: May 13 2009 14:54 | Format: PHP | Expires: never | Size: 3.13 KB | Hits: 1029

  1. <?php
  2. $user = $_SESSION['username'];
  3. $location = "files/";
  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['upload']['size']>640000)
  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'],$location.$user."-".$_FILES['upload']['name']))
  20.                   {
  21.         echo"<img src='images/pointers/delete.png' alt='ERROR' border='0'> <b>File could not move!</b>";
  22.                   exit;
  23.                   }
  24. echo "<br><img src='images/pointers/view.png' alt='SUCCES' border='0'> <b>The File: <a href='http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."' target='_blank'>".$user."-".$_FILES['upload']['name']."</a> Has Been Uploaded!</b>
  25. <br><br><br>
  26. <b>URL:</b><br>
  27. <input type='text' name='url' size='59' onclick='javascript:url.focus();url.select();' value='http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."' READONLY/>
  28. <br><br>
  29. <b>Link:</b><br>
  30. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  31. [url]http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."[/url]</textarea>
  32. <br><br>
  33. <b>Link with title:</b><br>
  34. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  35. [url=http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."]".$user."".$_FILES['upload']['name']."[/url]</textarea>
  36. <br><br>      
  37. <b>Image:</b><br>
  38. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  39. [img]http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."[/img]</textarea>
  40. <br><br>    
  41. <b>Thumbnail:</b><br>
  42. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  43. [thumb]http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."[/thumb]</textarea>
  44. <br><br>    
  45. <b>Image link:</b><br>
  46. <textarea name='textarea' onclick='javascript:textarea.focus();textarea.select();' cols='45' rows='4' READONLY>
  47. [link]http://www.xmoo.org/mytrainer/".$location."".$user."-".$_FILES['upload']['name']."[/link]</textarea>";
  48.    } else {
  49.    echo "<img src='images/pointers/delete.png' alt='ERROR' border='0'> <b>The Upload has failed!</b>"; }
  50. } else {
  51. echo '<center><form method="post" action="" enctype="multipart/form-data">
  52.     <b>File:</b> <input type="file" name="upload" size="50" /><br/> <br/>
  53.     <input type="submit" name="submit" value="Upload!" /></form></center>';
  54. }
  55. ?>