Guest
Public paste!

Untitled

By: a guest | Mar 19th, 2010 | Syntax: PHP | Size: 0.73 KB | Hits: 42 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. <?php
  2.  
  3.  
  4. $target = "upload/";
  5. $target = $target . basename( $_FILES['uploaded']['name']) ;
  6. $ok=1;
  7. $uploaded_size = $_FILES['uploaded']['size'];
  8. $uploaded_type = $_FILES['uploaded']['type'];
  9.  
  10.  
  11. //This is our size condition
  12. if ($uploaded_size > 3500000)
  13. {
  14. echo "Your file is too large.<br>";
  15. $ok=0;
  16. }
  17.  
  18.  
  19. //Here we check that $ok was not set to 0 by an error
  20. if ($ok==0)
  21. {
  22. Echo "Sorry your file was not uploaded";
  23. }
  24.  
  25. //If everything is ok we try to upload it
  26. else
  27. {
  28. if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
  29. {
  30. echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
  31. }
  32. else
  33. {
  34. echo "Sorry, there was a problem uploading your file.";
  35. }
  36. }
  37.  
  38. ?>