
<script type="text/javascript">
    $(document).ready(function (e) {
        $("#uploadForm").on('submit',(function(e) {
            e.preventDefault();
            $.ajax({
                url: "avatar_yuklash_forma.php",
                type: "POST",
                data:  new FormData(this),
                contentType: false,
                cache: false,
                processData:false,
                success: function(data)
                {
                    $("#targetLayer").body(data);
                }
                ,
                error: function() 
                {
                }
                
            }
                  );
        }
                                     ));
    }
                     );
</script>
<div class="bgColor">
    <form id="uploadForm" action="avatar_yuklash_forma.php" method="post">
        <div id="targetLayer">
            <?
        $session = get_session_details();
            $loggeduser = (object)$session->userdetails;
            $userid = $loggeduser->userid;

$foydalanuvchi_query = mysql_query("SELECT * FROM `users` WHERE `user_id` = '{$userid}'");
$user = mysql_fetch_assoc($foydalanuvchi_query);
                if (!file_exists(('' .base_url(). '' .$user['avatar']. ''))) {
                    echo '<img width="100" height="100" class="g-block_item-image ng-isolate-scope"  src="' .base_url(). '' .$user['avatar']. '"  /><br />';
                } else {
                    echo 'Avatar o\'rnatilmagan!';
                } ?>
        </div>
        <div id="uploadFormLayer">
            <label>
                Avatarni yuklash uchun bosing:
            </label>
            <br/>
            <input name="userImage" type="file" class="inputFile" />
            <input type="submit" value="Profilga o'rnatish" class="btnSubmit" />
        </form>
    </div>
</div>