Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <form action="https://mypensiony.co.il/panel/test.php" method="post" enctype="multipart/form-data">
  6. Your Photo: <input type="file" name="photo" size="25" />
  7. <input type="submit" name="submit" value="Submit" />
  8. </form>
  9. <?php
  10. //if they DID upload a file...
  11. if($_FILES['photo']['name'])
  12. {
  13. //if no errors...
  14. if(!$_FILES['photo']['error'])
  15. {
  16. //now is the time to modify the future file name and validate the file
  17. $new_file_name = strtolower($_FILES['photo']['tmp_name']); //rename file
  18. if($_FILES['photo']['size'] > (1024000)) //can't be larger than 1 MB
  19. {
  20. $valid_file = false;
  21. $message = 'Oops! Your file\'s size is to large.';
  22. }
  23.  
  24. //if the file has passed the test
  25. if($valid_file)
  26. {
  27. //move it to where we want it to be
  28. move_uploaded_file($_FILES['photo']['tmp_name'], 'uploads/'.$new_file_name);
  29. $message = 'Congratulations! Your file was accepted.';
  30. }
  31. }
  32. //if there is an error...
  33. else
  34. {
  35. //set that to be the returned message
  36. $message = 'Ooops! Your upload triggered the following error: '.$_FILES['photo']['error'];
  37. }
  38. }
  39. ?>
  40.  
  41.  
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement