Ciao ragazzi, questo script permette di caricare il profilo immagine per gli utenti registrati. Quando carico la foto o meglio quando premo il tasto per visualizzarla, dopo averla caricata la pagina diventa bianca e solo quando faccio refresh mi fa vedere la foto . Per il resto tutto funziona correttamente. questo il codice. Grazie!!
Codice PHP:
<h2>Hello, <?php echo $user_data['first_name'].' ' $user_data['last_name']; ?>!</h2>
        <div class="inner">
            <div class="profile">
                <?php
                
                
if(isset($_FILES['profile']) == true)
                {
                     
                    if(empty(
$_FILES['profile']['name']) == true)
                    {
                        echo 
'Please choose a file!';
                    }
                    else
                    {
                        
$allowed = array('jpg''jpeg''gif''png');

                        
$file_name $_FILES['profile']['name'];
                        
$file_size $_FILES['profile']['size'];
                        
$file_extn strtolower(end(explode('.'$file_name)));
                        
$file_temp $_FILES['profile']['tmp_name'];



                        if(
in_array($file_extn$allowed) == true && $file_size<(1024*1024) == true)
                        {
                            
change_profile_image($session_user_id$file_temp$file_extn);

                            
//header('Location: ' . $current_file);
                             
                            
exit();
                        }
                        else if(
$file_size<(1024*1024) == false)
                        {
                            echo  
"Image file size max 1 MB"
                        }
                        else
                        {
                            echo 
'Incorrect file type. Allowed: ';
                            echo 
implode(', '$allowed);
                        }
                    }
                }
                if(
file_exists($user_data['profile']))
                {
                    echo 
'[img]'$user_data['profile'], '[/img]';
                }
                else
                {
                    echo 
'[img]./images/profile/default.gif[/img]
'
;
                    echo 
'[b]Upload your picture[/b]';
                        
                }
                
                
/*if(empty($user_data['profile']) == false)
                {
                    echo '[img]', $user_data['profile'], '[/img]';
                }*/
                 
                
                
?>
                
                <form action="" method="post" enctype="multipart/form-data">
                    <input type="file" name="profile" > <input type="submit">
                </form>
            </div>
            <ul>
                [*]
                    [url="logout.php"]Log out[/url]
                
                [*]
                    [url="<?php echo $user_data['username'?>"]Profile[/url]
                
                [*]
                    [url="changepassword.php"]Change password[/url]
                
                [*]
                    [url="settings.php"]Settings[/url]
                
            [/list]
        </div>
    </div>
Questa e la funzione:
Codice PHP:
function change_profile_image($user_id$file_temp$file_extn)
{
    
$file_path 'images/profile/' substr(md5(time()), 010) . '.' $file_extn ;
    
move_uploaded_file($file_temp$file_path);
    
mysql_query("UPDATE users SET profile = '" $file_path .  "' WHERE user_id = "  . (int)$user_id);