Guest User

Untitled

a guest
May 24th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2. include('ajaximage/db.php'); //MySQL_ connection.
  3.  
  4. session_start();
  5. $s = session_id();
  6. $_iPATH = "profile_pic/_iThumbnail/";
  7.  
  8. $_iMGFORMATS = array( "jpg", "png", "gif", "bmp" );
  9. if( isset( $_POST ) and $_SERVER['REQUEST_METHOD'] == "POST" ) {
  10. $name = $_FILES['photoimg']['name'];
  11. $size = $_FILES['photoimg']['size'];
  12. if( strlen( $name ) ){
  13. list( $txt, $ext ) = explode( ".", $name );
  14. if( in_array( $ext, $_iMGFORMATS )){
  15. if( $size < (1024*1024) ){
  16. $_iMAGENAME = time( ).substr( str_replace(" ", "_", $txt), 5 ).".".$ext;
  17. $_iTMP = $_FILES['photoimg']['tmp_name'];
  18. if( move_uploaded_file( $_iTMP, $_iPATH.$_iMAGENAME ) ){
  19. mysql_query("UPDATE users SET _iProfilePicture='$_iMAGENAME' WHERE _iD='$s'");
  20. echo "<img src='profile_pic/_iThumbnail/".$_iMAGENAME."' class='preview'>";
  21. }
  22. else
  23. echo "failed";
  24. }
  25. else
  26. echo "Image file size max 1 MB";
  27. }
  28. else
  29. echo "Invalid file format..";
  30. }
  31. else
  32. echo "Please select image..!";
  33. exit;
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment