Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset($_POST['addcard'])) {
- $cardname = $_POST['card_input'];
- $rarity = $_POST['rarity_input'];
- $image_front = $_FILES['file']['name'];
- $image_back =
- $image_avatar =
- $image_sprite =
- $query = $pdo->prepare("INSERT INTO cards (name,rarity,img_front,img_back,img_avatar,img_sprite) VALUES (:name,:rarity,:img_front,:img_back,:img_avatar,:img_sprite)");
- $query->bindValue(":name", $cardname, PDO::PARAM_STR);
- $query->bindValue(":rarity", $rarity, PDO::PARAM_STR);
- $query->bindValue(":img_front", $image_front, PDO::PARAM_STR);
- $query->bindValue(":img_back", $image_back, PDO::PARAM_STR);
- $query->bindValue(":img_avatar", $image_avatar, PDO::PARAM_STR);
- $query->bindValue(":img_sprite", $image_sprite, PDO::PARAM_STR);
- $query->execute();
- if ($_FILES["file"]["error"] > 0) {
- echo "Error: " . $_FILES["file"]["error"] . "<br>";
- }
- else {
- echo "Upload: " . $_FILES["image_front"]["name"] . "<br>";
- echo "Type: " . $_FILES["image_front"]["type"] . "<br>";
- echo "Size: " . ($_FILES["image_front"]["size"] / 1024) . " kB<br>";
- echo "Stored in: " . $_FILES["image_front"]["tmp_name"];
- echo "<br>"
- echo "Upload: " . $_FILES["image_back"]["name"] . "<br>";
- echo "Type: " . $_FILES["image_back"]["type"] . "<br>";
- echo "Size: " . ($_FILES["image_back"]["size"] / 1024) . " kB<br>";
- echo "Stored in: " . $_FILES["image_back"]["tmp_name"];
- echo "<br>"
- echo "Upload: " . $_FILES["image_avatar"]["name"] . "<br>";
- echo "Type: " . $_FILES["image_avatar"]["type"] . "<br>";
- echo "Size: " . ($_FILES["image_avatar"]["size"] / 1024) . " kB<br>";
- echo "Stored in: " . $_FILES["image_avatar"]["tmp_name"];
- echo "<br>"
- echo "Upload: " . $_FILES["image_sprite"]["name"] . "<br>";
- echo "Type: " . $_FILES["image_sprite"]["type"] . "<br>";
- echo "Size: " . ($_FILES["image_sprite"]["size"] / 1024) . " kB<br>";
- echo "Stored in: " . $_FILES["image_sprite"]["tmp_name"];
- echo "<br>"
- }
- $allowedExts = array("gif", "jpeg", "jpg", "png");
- $temp = explode(".", $_FILES["file"]["name"]);
- $extension = end($temp);
- if ((($_FILES["file"]["type"] == "image/gif")
- || ($_FILES["file"]["type"] == "image/jpeg")
- || ($_FILES["file"]["type"] == "image/jpg")
- || ($_FILES["file"]["type"] == "image/pjpeg")
- || ($_FILES["file"]["type"] == "image/x-png")
- || ($_FILES["file"]["type"] == "image/png"))
- && in_array($extension, $allowedExts)) {
- if ($_FILES["file"]["error"] > 0) {
- echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
- }
- else {
- echo "Upload: " . $_FILES["file"]["name"] . "<br>";
- echo "Type: " . $_FILES["file"]["type"] . "<br>";
- echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
- echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
- if (file_exists("upload/" . $_FILES["file"]["name"])) {
- echo $_FILES["file"]["name"] . " already exists. ";
- }
- else {
- move_uploaded_file($_FILES["file"]["tmp_name"],
- "upload/" . $_FILES["file"]["name"]);
- echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
- }
- }
- }
- else {
- echo "Invalid file";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement