Guest User

Untitled

a guest
Feb 25th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. <b>Select file to upload:</b></br></br>
  2.  
  3.  
  4. <img id="output"/ width="200" height="200" src="<?php echo $row['StdImage']; ?>">
  5. <input type="file" class="btn btn-primary" name="stdimage" accept="image/*" onchange="loadFile(event)">
  6.  
  7. <?php include 'db.php';
  8. $id= $_POST['id'];
  9. if(isset($_POST['send'])){
  10.  
  11. $Stdid_one = htmlspecialchars($_POST['txtID']);
  12. $Lname = htmlspecialchars($_POST['txtLname']);
  13. $Fname = htmlspecialchars($_POST['txtFname']);
  14. $Mname = htmlspecialchars($_POST['txtMname']);
  15. $Track = htmlspecialchars($_POST['track_type']);
  16. $track_id = htmlspecialchars($_POST['txttrackid']);
  17. $YearLvl = htmlspecialchars($_POST['txtgrade']);
  18. $Bday = htmlspecialchars($_POST['txtBday']);
  19. $BirthPlace = htmlspecialchars($_POST['txtBplace']);
  20. $MTongue = htmlspecialchars($_POST['txtMtongue']);
  21. $IP = htmlspecialchars($_POST['txtIp']);
  22. $Religion = htmlspecialchars($_POST['txtReligion']);
  23. $Street = htmlspecialchars($_POST['txtStreet']);
  24. $Barangay = htmlspecialchars($_POST['txtBrgy']);
  25. $Munic = htmlspecialchars($_POST['txtMunic']);
  26. $Province = htmlspecialchars($_POST['txtProv']);
  27. $Gender = htmlspecialchars($_POST['rbgender']);
  28. $Father = htmlspecialchars($_POST['txtfather']);
  29. $Mother = htmlspecialchars($_POST['txtmother']);
  30. $Guardian = htmlspecialchars($_POST['txtGuard']);
  31. $GuardRelation = htmlspecialchars($_POST['txtGuardRelation']);
  32. $Contact = htmlspecialchars($_POST['txtcontact']);
  33. $Remarks = htmlspecialchars($_POST['txtRemarks']);
  34. $formone= htmlspecialchars($_POST['chkfone']);
  35. $envelope= htmlspecialchars($_POST['chkenvelope1']);
  36. $onebyone= htmlspecialchars($_POST['chk1x1']);
  37. $birth= htmlspecialchars($_POST['chkbirth']);
  38. $twocopies= htmlspecialchars($_POST['chk2copies']);
  39. $ncae= htmlspecialchars($_POST['chkncae']);
  40. $goodmoral= htmlspecialchars($_POST['chkgoodmoral']);
  41. $formtwo= htmlspecialchars($_POST['chkform137']);
  42. $diploma= htmlspecialchars($_POST['chkdiploma']);
  43. $bothpic= htmlspecialchars($_POST['chkbothpic']);
  44. $except= htmlspecialchars($_POST['chkexcept']);
  45.  
  46. $target_dir = "StdImage/";
  47. $file = basename($_FILES["stdimage"]["name"]);
  48. $target_file = $target_dir . basename($_FILES["stdimage"]["name"]);
  49. $uploadOk = 1;
  50. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  51. // Check if image file is a actual image or fake image
  52. if(isset($_POST["submit"])) {
  53. $check = getimagesize($_FILES["stdimage"]["tmp_name"]);
  54. if($check !== false) {
  55. echo "File is an image - " . $check["mime"] . ".";
  56. $uploadOk = 1;
  57. } else {
  58. echo "File is not an image.";
  59. $uploadOk = 0;
  60. }
  61. }
  62. // Check if file already exists
  63. if (file_exists($target_file)) {
  64. echo "Sorry, file already exists.";
  65. $uploadOk = 0;
  66. }
  67. // Check file size
  68. if ($_FILES["stdimage"]["size"] > 500000000000) {
  69. echo "Sorry, your file is too large.";
  70. $uploadOk = 0;
  71. }
  72. // Allow certain file formats
  73. if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
  74. && $imageFileType != "gif" ) {
  75. echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
  76. $uploadOk = 0;
  77. }
  78. // Check if $uploadOk is set to 0 by an error
  79. if ($uploadOk == 0) {
  80. echo "Sorry, your file was not uploaded.";
  81. // if everything is ok, try to upload file
  82. } else {
  83. if (move_uploaded_file($_FILES["stdimage"]["tmp_name"], $target_file)) {
  84. echo "The file ". basename( $_FILES["stdimage"]["name"]). " has been uploaded.";
  85. } else {
  86. echo "Sorry, there was an error uploading your file.";
  87. }
  88. }
  89.  
  90. $sql2 ="UPDATE tblstdpro SET StdImage='$target_file', Lname='$Lname', Fname='$Fname', Mname='$Mname', Track='$Track', track_id='$track_id', YearLvl='$YearLvl', Bday='$Bday', Birthplace='$BirthPlace', MTongue='$MTongue', IP='$IP', Religion='$Religion', Street='$Street', Barangay='$Barangay', Munic='$Munic', Province='$Province', Gender='$Gender', Father='$Father', Mother='$Mother', GuardianName='$Guardian', GuardRelation='$GuardRelation', Contact='$Contact', Remarks='$Remarks', form138='$formone', envelope1='$envelope', 1x1picture='$onebyone', psa='$birth', 2x2picture='$twocopies', ncae='$ncae', goodmoral='$goodmoral', form137='$formtwo', diploma='$diploma', bothpicture='$bothpic', alloriginal='$except' WHERE StdID ='$Stdid_one'";
  91.  
  92. $db->query($sql2);
  93.  
  94. header('location: StudentDatabase.php');
  95.  
  96. }
  97. ?>
Add Comment
Please, Sign In to add comment