Php 成功上载文件后显示Javascript警报()

Php 成功上载文件后显示Javascript警报(),php,javascript,Php,Javascript,我有一个小的上传系统来上传个人资料图片。 我想显示一个带有1个按钮的警报框(已成功上载)。 以下是我的php上传功能: function change_profile_image($user_id, $file_temp, $file_extn){ $file_path = substr(md5(time()), 0, 10) . '.' . $file_extn; move_uploaded_file($file_temp, 'images/profile/'.$file_pa

我有一个小的上传系统来上传个人资料图片。 我想显示一个带有1个按钮的警报框(已成功上载)。 以下是我的php上传功能:

function change_profile_image($user_id, $file_temp, $file_extn){
    $file_path = substr(md5(time()), 0, 10) . '.' . $file_extn;
    move_uploaded_file($file_temp, 'images/profile/'.$file_path);
    Thumbnail('images/profile/', $file_path, 'images/thumbs/');
    mysql_query("UPDATE `users` SET `profile` = 'images/profile/" . mysql_real_escape_string($file_path) . "' WHERE `user_id` = " . (int)$user_id);
}
下面是我如何调用函数的:

if (in_array($file_extn, $allowed) === true) {
                        change_profile_image($session_user_id, $file_temp, $file_extn);
                        header('Location: ' . $current_file);
                        exit();
                    }

这可能是jQuery的工作。事实上,可能是这样

但第二个(也是更简单的)选项可能是传递GET参数作为确认:

header("Location: {$current_file}?loaded=ok");
然后在“当前文件”中检查,可能在正文末尾:

if (isset($_GET['loaded'])) {
    if ('ok' == $_GET['loaded'])
        $msg = "Loaded OK!";
    else
        $msg = "Oh noes! Error {$_GET['loaded']} while updating picture";
    // Remember, keep $msg without 'quote' "signs", or \"escape\" them properly
    print <<<DISPLAY_ALERT
<script>
    alert('$msg');
</script>
DISPLAY_ALERT;
}
if(isset($\u GET['loaded'])){
如果('ok'=$\u GET['loaded'])
$msg=“已加载确定!”;
其他的
$msg=“噢,不!更新图片时出错{$\u GET['loaded']}”;
//记住,保持$msg不带“引号”或“转义”符号

打印,那么,这有什么问题吗?我想在上传图片时显示一个警告框,显示上传成功。我在打印时遇到了问题,所以我简化了它,如果(isset($\u GET['loaded']){if($'ok'=$\u GET['loaded']){$msg=“loaded ok!”;print“alert('$msg');“}有什么问题吗?