简体   繁体   中英

PHP session doesn't pass through files

I am using Uploadify for my script.

The main page:

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

?>

I'm sure it gets to the $_SESSION['uploaded_files'][] = $file_hash; part, since the actual file is uploaded to the directory. My problem is that the var_dump of $_SESSION['uploaded_files'] returns null.

The files are in the same directory level.

Thanks in advance.

I found the solution. The problem is that Uploadify's flash version is treated as a different client for the server, therefore the server creates a new session id for it.

I followed this topic: http://www.uploadify.com/forum/#/discussion/43 Hope it'll help others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM