如何检查会话变量是否传递给uploadify

如何检查会话变量是否传递给uploadify

本文介绍了如何检查会话变量是否传递给uploadify.php?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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!

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

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.

我在下面包含了完整的uploadify.php脚本,以防万一.

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

谢谢,

尼克

<?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) 很有用

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

记住,你只能在session_start();

这篇关于如何检查会话变量是否传递给uploadify.php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 18:43