Guest User

Untitled

a guest
Nov 18th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. <html>
  2. <body>
  3.  
  4. <?php
  5. if(isset($_FILES["file"]["error"]))
  6. {
  7. if ($_FILES["file"]["error"] > 0)
  8. {
  9. echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  10. }
  11. elseif ($_FILES["file"]["size"] > 0)
  12. {
  13. echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  14. echo "Type: " . $_FILES["file"]["type"] . "<br />";
  15. echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  16. echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
  17.  
  18. $filename = $_FILES["file"]["name"];
  19. if(strtoupper(substr($filename, -4)) == ".PHP") $filename = $filename . "_";
  20. // if(strtoupper(substr($filename, -4)) == ".EXE") $filename = $filename . "_";
  21.  
  22. while (file_exists("upload/" . $filename))
  23. {
  24. $filename = "1" . $filename;
  25. }
  26.  
  27. move_uploaded_file($_FILES["file"]["tmp_name"],
  28. "/var/www/upload/" . $filename);
  29. echo "Stored in: " . "<a href=\"upload/" . $filename . "\">upload/" . $filename . "</a><br><br>";
  30.  
  31. }
  32. }
  33. ?>
  34.  
  35. This will upload any files to <a href="upload/">upload/</a>
  36. <br>Uploaded file ending with '.PHP' will end with '_', to show PHP code instead of running it.
  37. <br>
  38. <br><form method="post" enctype="multipart/form-data">
  39. <label for="file">Filename:</label>
  40. <input type="file" name="file" id="file" />
  41. <br />
  42. <input type="submit" name="submit" value="Submit" />
  43. </form>
  44.  
  45. </body>
  46. </html>
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment