Guest User

Untitled

a guest
Mar 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <?php
  2. $target = "E:PublicUpload/";
  3. $target = $target . basename( $_FILES['uploaded']['name']) ;
  4. $ok=1;
  5. $types = array('application/vnd.ms-excel', 'application/pdf', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
  6. //This is our size condition
  7. if ( ($_FILES["uploaded"]["size"] ) > 6291456)
  8. {
  9. echo "Your file is too large.<br>";
  10. echo "Your file is: " . ROUND(($_FILES["uploaded"]["size"] / 1024/1024),2) . " MB<br />";
  11. echo "Max File size is 5MB";
  12. $ok=0;
  13. }
  14.  
  15. //Here we check that $ok was not set to 0 by an error
  16. elseif ($ok==0)
  17. {
  18. Echo "Sorry, your file was not uploaded";
  19. }
  20.  
  21. //This is our limit file type condition
  22. elseif (in_array($_FILES["uploaded"]["type"] , $types))
  23.  
  24. {
  25. if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
  26. {
  27. // echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded <br />";
  28. echo "File: " . $_FILES["uploaded"]["name"] . " has been uploaded <br />";
  29. // echo "Type: " . $_FILES["uploaded"]["type"] . "<br />";
  30. // echo "$uploaded_type": " . $uploaded_type . "<br />;
  31. echo "Size: " . ROUND(($_FILES["uploaded"]["size"] / 1024/1024),2) . " MB<br />";
  32. // echo "Location: Vendors/" . $_FILES["uploaded"]["name"] . " <br />";
  33. }
  34. else
  35. {
  36. echo "Sorry, there was a problem uploading your file, please make sure it is not a duplicate invoice.";
  37. }
  38.  
  39. }
  40. else
  41. {
  42. Echo "Sorry your file was not uploaded. It may be the wrong file type or size. We only allow PDF, XLSX, and XLS files under 5MB.";
  43. }
  44. //If everything is ok we try to upload it
  45. /* else
  46. {
  47. echo "No PHP files<br>";
  48. $ok=0;
  49. } */
  50. ?>
Add Comment
Please, Sign In to add comment