fetch_assoc(); $dir = $relative_dir . "download/" . $result['uid']; $target_file = $dir . "/" . $filename; //Create the directory if (! file_exists($dir)) { mkdir($dir, 0755, true); } $extension = pathinfo($target_file,PATHINFO_EXTENSION); //Try to move the file if (! move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) { header("Location: /ptf-admin/add?success=false"); exit; } //Update the database $stmt = $mysqli->prepare("INSERT INTO file (`name`, `uid`, `file`, `project-id`) VALUES (?,?,?,?)"); $stmt->bind_param("sssi", $name, $uid, $filename, $project); $stmt->execute(); $stmt->close(); header("Location: /ptf-admin/add?success=true"); ?>