PHP会话不通过文件

时间:2012-07-22 05:30:14

标签: php session uploadify

我正在使用Uploadify作为我的脚本。

主页:

<?php

session_start();

var_dump($_SESSION);
$uploaded_files = $_SESSION['uploaded_files'];

?>

//Uploadify, HTML forms and more (not related, No PHP in this section)

uploadify.php:

<?php

session_start();

require_once('includes/functions.php');

// Define a destination
$targetFolder = 'uploads/temp'; // Relative to the root

if (!empty($_FILES)) {
    $fileParts = pathinfo($_FILES['Filedata']['name']);
    $file_hash = GenRndStr(20) . '.' . $fileParts['extension'];
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $file_hash;

    // Validate the file type
    $fileTypes = array(); // File extensions

    move_uploaded_file($tempFile, $targetFile);
    $_SESSION['uploaded_files'][] = $file_hash;
    echo '1';
}

?>

我确信它会进入$_SESSION['uploaded_files'][] = $file_hash;部分,因为实际文件已上传到目录。我的问题是var_dump的{​​{1}}返回null。

文件位于同一目录级别。

提前致谢。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。问题是Uploadify的flash版本被视为服务器的不同客户端,因此服务器为它创建一个新的会话ID。

我遵循了这个主题:http://www.uploadify.com/forum/#/discussion/43 希望它能帮助别人。

相关问题