0
我正在爲我的腳本使用Uploadify。PHP會話不通過文件
主要頁面:
<?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;
一部分,因爲實際的文件上傳到目錄中。我的問題是$_SESSION['uploaded_files']
的var_dump
返回null。
這些文件位於相同的目錄級別。
在此先感謝。
上面'var_dump'的輸出是什麼?在最後一個'}之後的第二個文件中'$ SESSION'的var_dump是什麼?什麼是實際過程?你通過uploadify.php上傳文件,將哈希存儲在會話中,並且不能在後面顯示的main.php中訪問它們?此外,'session_start();'之後'echo session_id();'的輸出可能會提示您是否要訪問同一個會話。 – PhilMasterG 2012-07-22 06:26:21
第一次轉儲給出空,第二次給出正確的列表 – Novak 2012-07-22 07:11:06
我現在看到,頁面生成不同的會話ID。這怎麼可能?感謝您指出這一點,我一直在坐幾個小時試圖解決它。 – Novak 2012-07-22 07:11:27