丢失了变量i脚本

Lost variable i script

本文关键字:脚本 变量      更新时间:2023-09-26

我有一些问题与变量在我的脚本,我需要"发送"变量通过一些不同的文件

变量来自链接:

index.php?email=emailname@emailname.com

该脚本为文件上传脚本。在这个过程中使用了3个文件,请在这里:

/public_html/upload/index.php
/public_html/upload/content/index.php
/public_html/upload/content/UploadHandler.php

/public_html/upload/index.php是运行脚本和从链接接收变量的地方:index.php?email=emailname@emailname.com

/public_html/upload/index.php的文件代码如下:

<?php
// change the name below for the folder you want
$dir = "content/".$_GET["email"];
$file_to_write = 'test.txt';
$content_to_write = "The content";
if( is_dir($dir) === false )
{
    mkdir($dir);
}
$file = fopen($dir . '/' . $file_to_write,"w");
// a different way to write content into
// fwrite($file,"Hello World.");
fwrite($file, $content_to_write);
// closes the file
fclose($file);
// this will show the created file from the created folder on screen
include $dir . '/' . $file_to_write;
$_SESSION['tmem']= $_GET["email"];
?>

我知道$_GET["email"]工作,因为我可以在index.php文件上的代码:<?=$_GET["email"]?>,看看它是否接收变量。

代码:

$_SESSION['tmem']= $_GET["email"];

应该将变量转发到下一个文件:

/public_html/upload/content/index.php

看起来像这样:

session_start();
$dir = "content/" . $_GET["email"];
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
$upload_handler = new UploadHandler( array ('upload_url' =>$dir) );

并且该代码应该将变量转发到上传补丁所在脚本的代码中。文件:/public_html/upload/content/UploadHandler.php上的代码如下:

'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/'.$_GET['email'].'/',  
'upload_url' => $this->get_full_url().'/'.$_GET['email'].'/',           
'input_stream' => 'php://input',
'user_dirs' => false,
'mkdir_mode' => 0755,
'param_name' => 'files',

有人能看到在这个过程中我丢失了变量吗?

我认为,在这部分代码中:

session_start();
$dir = "content/" . $_GET["email"];

您尝试从URI获取您的"email",而不是从会话(tmem)获取。