丢失了变量i脚本
Lost variable i script
我有一些问题与变量在我的脚本,我需要"发送"变量通过一些不同的文件
变量来自链接:
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)获取。
相关文章:
- 在 ActionLink mvc3 Razor 中使用 java 脚本变量
- Rails 4-使用脚本变量作为按钮值
- 如何使用java脚本变量使用Django反向URL
- 如何将PHP中的变量插入到具有直接变量的Java脚本变量中
- 如何在scriplet中使用脚本变量
- 将java脚本变量传递给相同的表单操作php文件参数
- 将 PHP 数据从mysql_fetch_array保存为脚本变量
- 如何在 AngularJS 中访问模板脚本变量
- 将 PHP 变量保存到函数中的脚本变量
- 如何在 PHP 标签中访问 java 脚本变量
- 检索 JSP 脚本变量中的隐藏输入值,而无需提交页面
- 咖啡脚本变量声明放在错误的位置
- 如何检查两个 java 脚本变量是否不同
- 在另一个 html 文件中获取 java 脚本变量
- 删除开头的双引号&结束于JSON对象/字符串或Java脚本变量
- drupal7为页眉和页脚拆分脚本变量
- 将java脚本变量的值插入到php变量中
- 将脚本变量限制为Google sheets中的特定工作表
- 如何将html脚本变量传递给控制器
- 如何在锚点的rel属性中传递java脚本变量的值