Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. // Your file name you are uploading
  4.  
  5. $file_name = $POST['avatar'];
  6. $userNameToSave = $req_user_info['username'];
  7.  
  8. //set where you want to store files
  9. //in this example we keep file in folder upload
  10. //$userNameToSave = new upload file name
  11. //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
  12. $path= "../users/".$userNameToSave."/images/";
  13. if($ufile !=none)
  14. {
  15. if(copy($POST['avatar']['tmp_name'], $path))
  16. {
  17. include("../include/session.php");
  18. $host="localhost"; // Host name
  19. $username="root"; // Mysql username
  20. $password="757794000708"; // Mysql password
  21. $db_name="IDEA"; // Database name
  22. $tbl_name="users"; // Table name
  23.  
  24. // Connect to server and select database.
  25. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  26. mysql_select_db("$db_name")or die("cannot select DB");
  27.  
  28. $avatar="../users/".$req_user_info['username']."/".$req_user_info['username'].".jpg";
  29.  
  30. $sql="INSERT INTO $tbl_name(avatar)VALUES('$avatar')";
  31. $result=mysql_query($sql);
  32.  
  33. if($result){
  34. echo "Successful<BR>";
  35. echo "<a href=../main_page.php>Back to Profile</a>";
  36. }
  37. else {
  38. echo "ERROR";
  39. }
  40. mysql_close();
  41. }
  42. else
  43. {
  44. echo "Error";
  45. }
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement