如何检查会话变量是否被传递给上传.php


How can I check whether session variables are getting passed to uploadify.php?

我在上传 (v3.1) 中通过 formData 选项传递会话数据的解决方法时遇到了一些困难。我已经实施了此页面上的建议,但是我收到HTTP 500错误。

我想知道如何检查我的会话中的内容,以查看解决方法是否真的有效,即我的会话 ID 是否真的被传递给 uploadify.php。返回 uploadify 中回显的变量的常用方法是 onUploadSuccess 事件.php但我不能使用它,因为上传没有成功完成!

所以我想知道我还有什么其他选择。 我知道诸如 var_dump( $_SESSION );die(print($_SESSION)); ,但我不知道在哪里查找这些返回的信息。

我在下面包含完整的上传.php脚本,以防有帮助。

谢谢

缺口

<?php
$session_name = session_name();
if (!isset($_POST[$session_name])) {
    exit;
} else {
    session_id($_POST[$session_name]);
    session_start();
}
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php&gt; 
*/
// Define a destination
$targetPath = 'media/' . $_SESSION["user_name"] . '/';
if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetFile = $targetPath . $_FILES['Filedata']['name'];
    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);
    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);
        echo '1';
    } else {
        echo 'Invalid file type.';
    }
}
?>
您也可以

使用print_r($_SESSION),但var_dump($_SESSION)也很有用。

请记住,您只能在session_start();后使用