johnlawrence

http://cut-urls.com/UgUYLE0

Apr 25th, 2017
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <?php
  2. require uploader.php;
  3.  
  4. //General Error Check
  5.  
  6. if ($_FILES["file"]["error"] > 0){
  7. echo "<SCRIPT>alert('Sorry, there has been an error while uploading Please Try Again');</SCRIPT>";
  8. echo "Return Code: ".$_FILES["file"]["error"]."<br>";
  9. //redirect to the main upload page
  10. die(reciever.php);
  11. header("Location:uploader.php");
  12.  
  13.  
  14.  
  15. }else{
  16. echo "Upload: ".$_FILES["file"]["name"]."<br>";
  17. echo "<SCRIPT>alert('File Uploaded Successfully !');</SCRIPT>";
  18.  
  19. }
  20.  
  21. //Image Extention Check
  22. if( $_FILES["file"]["type"]=='jpg' || 'gif' || 'tif' || 'bmp'|| 'doc' || 'docx' ||'xls'||'xlsx'){
  23.  
  24. echo "Type: ".$_FILES["file"]["type"]."<br>";
  25. }else{
  26.  
  27. echo"Error, Extentions other than pictures or documents is prohibited"."<br>";
  28. }
  29. //Check File Size
  30.  
  31. if($_FILES["file"]["size"] / 1048576 > 5){ //Larger than 5 MB is prohibited
  32. echo"File size IS LARGER than 5 MB \r\n Return Code:".($_FILES["file"]["error"])."<br>";
  33.  
  34. }else{
  35. echo "Size:".($_FILES["file"]["size"] / 1048576)." MB <br>";
  36. }
  37.  
  38. echo "Temp file:". $_FILES["file"]["tmp_name"]."<br>";
  39.  
  40.  
  41. //Check if File's already been uploaded
  42.  
  43. if (file_exists("upload/".($_FILES["file"]["name"]))){
  44. echo $_FILES["file"]["name"] . " already exists.";
  45.  
  46. // If it's not uploaded , then :
  47. }else{
  48.  
  49. //Then Save it !
  50. move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$_FILES["file"]["name"]);
  51. echo "Stored in: "."upload/" . $_FILES["file"]["name"]."<br>";
  52. }
  53.  
  54. ?>
Add Comment
Please, Sign In to add comment