Advertisement
Guest User

Untitled

a guest
May 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $id = $_SESSION['user_id'];
  4. $pic = $_FILES['pic']["name"];
  5. $folder = "../images/users/";
  6. move_uploaded_file($_FILES['pic']["tmp_name"], "$folder".$pic);
  7.  
  8. $mysqli = connectDB();
  9. upload($id,$pic,$mysqli);
  10. ?>
  11.  
  12. function upload($id,$pic,$mysqli)
  13. {
  14. $pic = $mysqli->real_escape_string($pic);
  15.  
  16. $sql = "UPDATE users SET pic = '$pic' WHERE id = '$id'";
  17. $result = $mysqli->query($sql);
  18. }
  19.  
  20. <form name="submit" action="include/upload.php" method="post">
  21. <input type="file" value="Choose file" accept="image/*" id="pic" name="pic">
  22. <input type="submit" value="Upload" name="submit">
  23. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement