Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <form name="form1" method="post">
  2. <div class="form-group">
  3. <label for="exampleFormControlFile1">Select a custom profile picture</label>
  4. <input type="file" class="form-control-file" name ="f1" >
  5. <input type ="submit" class="form-control-submit" name="submit1" value="Upload">
  6.  
  7.  
  8. </div>
  9. </form>
  10.  
  11. <?php
  12. if(isset($_POST["submit1"]))
  13. {
  14.  
  15. $tm=md5(time());
  16. $fnm=$_FILES["f1"]["name"];
  17. $dst="./images/".$tm.$fnm;
  18. $dst1="images/".$tm.$fnm;
  19.  
  20. move_uploaded_file($_FILES["f1"]["tmp_name"],$dst);
  21.  
  22.  
  23. $res2=mysqli_query($link,"SELECT * FROM image WHERE uid = $_SESSION[uid]");
  24. $row2 = mysqli_fetch_array($res2);
  25.  
  26. if(empty($row2["image"])){
  27. mysqli_query($link,"INSERT INTO image values('$_SESSION[uid]','$dst1')");
  28.  
  29. }else{
  30. mysqli_query($link,"UPDATE image SET image= '$dst1' WHERE uid = '$_SESSION[uid]' ");
  31. }
  32.  
  33.  
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement