Advertisement
Guest User

upload.php

a guest
Nov 1st, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $server = "db707706878.db.1and1.com:3306";
  4. $username = "dbo707706878";
  5. $password = "p135qDdbH@ndl3r";
  6. $dbname = "db707706878";
  7. $conn = new mysqli($server,$username,$password,$dbname);
  8. if ($conn->connect_error) {
  9. die("Connection failed: " . $conn->connect_error);
  10. }
  11. $target_dir = "uploads/";
  12. $userid = $_SESSION['userid'];
  13. $target_file = "uploads/$userid.mp4";
  14. $uploadOk = 1;
  15. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  16. // Check if file already exists
  17. if (file_exists($target_file)) {
  18. echo "Sorry, file already exists.";
  19. $uploadOk = 0;
  20. }
  21. // Check file size
  22. if ($_FILES["fileToUpload"]["size"] > 50000000) {
  23. echo "Sorry, your file is too large.";
  24. $uploadOk = 0;
  25. }
  26. // Allow certain file formats
  27. if($imageFileType != "mp4"&&$imageFileType!="mov") {
  28. echo "Sorry, only MP4 and MOV files are allowed.";
  29. $uploadOk = 0;
  30. }
  31. // Check if $uploadOk is set to 0 by an error
  32. if ($uploadOk == 0) {
  33. die(" <a href='request.php'>Click here to return</a>");
  34. // if everything is ok, try to upload file
  35. } else {
  36. if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
  37. echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
  38. echo " <a href='exit.php'>Click here to log out</a>";
  39. $sql = "
  40. UPDATE `db707706878`.`users` SET `uploaded` = '1' WHERE `users`.`id` = $userid;";
  41. $result = $conn->query($sql);
  42. } else {
  43. echo "Sorry, there was an error uploading your file.";
  44. die(" <a href='request.php'>Click here to return</a>");
  45. }
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement