Advertisement
Sparkster

Untitled

Jul 24th, 2013
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(isset($_POST['addcard'])) {
  2.     $cardname = $_POST['card_input'];
  3.     $rarity = $_POST['rarity_input'];
  4.     $image_front = $_FILES['file']['name'];
  5.     $image_back =
  6.     $image_avatar =
  7.     $image_sprite =
  8.  
  9.     $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)");
  10.     $query->bindValue(":name", $cardname, PDO::PARAM_STR);
  11.     $query->bindValue(":rarity", $rarity, PDO::PARAM_STR);
  12.     $query->bindValue(":img_front", $image_front, PDO::PARAM_STR);
  13.     $query->bindValue(":img_back", $image_back, PDO::PARAM_STR);
  14.     $query->bindValue(":img_avatar", $image_avatar, PDO::PARAM_STR);
  15.     $query->bindValue(":img_sprite", $image_sprite, PDO::PARAM_STR);
  16.     $query->execute();
  17.  
  18. if ($_FILES["file"]["error"] > 0) {
  19.     echo "Error: " . $_FILES["file"]["error"] . "<br>";
  20. }
  21.  
  22. else {
  23.     echo "Upload: " . $_FILES["image_front"]["name"] . "<br>";
  24.     echo "Type: " . $_FILES["image_front"]["type"] . "<br>";
  25.     echo "Size: " . ($_FILES["image_front"]["size"] / 1024) . " kB<br>";
  26.     echo "Stored in: " . $_FILES["image_front"]["tmp_name"];
  27.     echo "<br>"
  28.     echo "Upload: " . $_FILES["image_back"]["name"] . "<br>";
  29.     echo "Type: " . $_FILES["image_back"]["type"] . "<br>";
  30.     echo "Size: " . ($_FILES["image_back"]["size"] / 1024) . " kB<br>";
  31.     echo "Stored in: " . $_FILES["image_back"]["tmp_name"];
  32.     echo "<br>"
  33.     echo "Upload: " . $_FILES["image_avatar"]["name"] . "<br>";
  34.     echo "Type: " . $_FILES["image_avatar"]["type"] . "<br>";
  35.     echo "Size: " . ($_FILES["image_avatar"]["size"] / 1024) . " kB<br>";
  36.     echo "Stored in: " . $_FILES["image_avatar"]["tmp_name"];
  37.     echo "<br>"
  38.     echo "Upload: " . $_FILES["image_sprite"]["name"] . "<br>";
  39.     echo "Type: " . $_FILES["image_sprite"]["type"] . "<br>";
  40.     echo "Size: " . ($_FILES["image_sprite"]["size"] / 1024) . " kB<br>";
  41.     echo "Stored in: " . $_FILES["image_sprite"]["tmp_name"];
  42.     echo "<br>"
  43. }
  44.  
  45. $allowedExts = array("gif", "jpeg", "jpg", "png");
  46. $temp = explode(".", $_FILES["file"]["name"]);
  47. $extension = end($temp);
  48. if ((($_FILES["file"]["type"] == "image/gif")
  49. || ($_FILES["file"]["type"] == "image/jpeg")
  50. || ($_FILES["file"]["type"] == "image/jpg")
  51. || ($_FILES["file"]["type"] == "image/pjpeg")
  52. || ($_FILES["file"]["type"] == "image/x-png")
  53. || ($_FILES["file"]["type"] == "image/png"))
  54. && in_array($extension, $allowedExts)) {
  55.     if ($_FILES["file"]["error"] > 0) {
  56.         echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
  57.         }
  58.  
  59.   else {
  60.     echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  61.     echo "Type: " . $_FILES["file"]["type"] . "<br>";
  62.     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  63.     echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
  64.  
  65.     if (file_exists("upload/" . $_FILES["file"]["name"])) {
  66.         echo $_FILES["file"]["name"] . " already exists. ";
  67.         }
  68.  
  69.     else {
  70.         move_uploaded_file($_FILES["file"]["tmp_name"],
  71.         "upload/" . $_FILES["file"]["name"]);
  72.         echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  73.         }
  74.     }
  75. }
  76.  
  77. else {
  78.     echo "Invalid file";
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement