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

夙愿已清 提交于 2019-12-12 06:25:03

问题


I am having some difficulty with the workaround method in uploadify (v3.1) for passing session data via the formData option. I have implemented the suggestion on this page, but I am getting an HTTP 500 Error.

I am wondering how to check what is in my session, to see if the workaround is really working, i.e. if my session ID is really getting passed to uploadify.php. The usual method for returning variables echoed in uploadify.php is the onUploadSuccess event, but I can't use this, as uploads aren't completing successfully!

So I am wondering what other options I have. I am aware of methods such as var_dump( $_SESSION ); or die(print($_SESSION));, but I don't know where to look for the info these are returning.

I include the full uploadify.php script below, in case it is helpful.

Thanks,

Nick

<?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.';
    }
}

?>

回答1:


You can use print_r($_SESSION) as well, but var_dump($_SESSION) is useful too.

Remember, you only use after session_start();



来源:https://stackoverflow.com/questions/10735847/how-can-i-check-whether-session-variables-are-getting-passed-to-uploadify-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!