Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $server = "db707706878.db.1and1.com:3306";
- $username = "dbo707706878";
- $password = "p135qDdbH@ndl3r";
- $dbname = "db707706878";
- $conn = new mysqli($server,$username,$password,$dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $target_dir = "uploads/";
- $userid = $_SESSION['userid'];
- $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
- echo "$target_file";
- $uploadOk = 1;
- $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
- // Check if file already exists
- if (file_exists($target_file)) {
- echo "Sorry, file already exists.";
- $uploadOk = 0;
- }
- // Check file size
- if ($_FILES["fileToUpload"]["size"] > 50000000) {
- echo "Sorry, your file is too large.";
- $uploadOk = 0;
- }
- // Allow certain file formats
- if($imageFileType != "mp4") {
- echo "Sorry, only MP4 files are allowed.";
- $uploadOk = 0;
- }
- // Check if $uploadOk is set to 0 by an error
- if ($uploadOk == 0) {
- die(" <a href='request.php'>Click here to return</a>");
- // if everything is ok, try to upload file
- } else {
- if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
- echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
- echo " <a href='exit.php'>Click here to log out</a>";
- $sql = "
- UPDATE `db707706878`.`users` SET `uploaded` = '1' WHERE `users`.`id` = $userid;";
- $result = $conn->query($sql);
- } else {
- echo "Sorry, there was an error uploading your file.";
- die(" <a href='request.php'>Click here to return</a>");
- }
- }
- ?>
Add Comment
Please, Sign In to add comment