php - php $_GET 和未定义的索引 P
问题描述
我在不同的 PHP 服务器上运行我的脚本时遇到问题,在我的旧服务器上,以下代码似乎工作正常 - 即使声明了 p 参数。
<?php
$ACCESSKEY="demo";
header('Cache-Control: no-cache, must-revalidate');
if($_GET['p']==$ACCESSKEY){
// this is the workaround for file_get_contents(...)
require_once (dirname(__FILE__).'/PHP_Compat-1.6.0a3/Compat/Function/file_get_contents.php');
$data = php_compat_file_get_contents('php://input');
$filename = $_GET['filename'];
if (file_put_contents($filename,$data)) {
if (filesize($filename) != 0) {
echo "Upload success";
} else {
header("HTTP/1.0 400 Bad Request");
echo "bad request";
}
} else {
header("HTTP/1.0 400 Bad Request");
echo "failed.";
}
} else {
header("HTTP/1.0 400 Bad Request");
echo "Access denied";
}
?>
和这样的错误:
Notice: Undefined index: p in C:\xampp\htdocs\upload\index.php on line 5
我该如何解决?谢谢
解决方案
推荐阅读
- azure-cognitive-search - Azure 搜索错误:对于小数点的 gt 或 ge 运算符,过滤双精度相同
- spring - 如何从 javax.persistence.EntityManger 获取连接字符串
- javascript - 从javascript中的视频中获取像素处的YUV而不是RGB
- python - 在 Python 中的列表中查找最长和最短的列表
- java - MongoDb Java API 更新失败
- python-3.x - 查询期间丢失与 MySQL 服务器的连接 - Python 3.x - pymysql
- android - 使用滑行在图像视图中显示文本
- c++ - QueryChangesVirtualDisk() 正在返回 Access_Denied (5)?
- ios - 无需点击通知即可获取收到的推送通知列表
- c++ - 重载多个函数的简写