丢失变量i脚本

时间:2016-10-29 22:42:36

标签: javascript php

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

变量来自链接:

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"]有效,因为<?=$_GET["email"]?>文件上的代码index.php可以查看它是否收到变量。

代码:

$_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',

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

1 个答案:

答案 0 :(得分:-1)

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

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

你试着收到你的电子邮件&#34;来自URI而不是从session(tmem)获取它。