我正在try 制作一个脚本,该脚本将用作监视系统,但我收到一个问题错误:

注意:未定义变量:KEEP_FOR_LATH第47行

但这个变量设置在第39行.

有什么主意吗?

以下是我的php:

<?php
print_r($_FILES["file"]);
$file_name = $_FILES["file"]["tmp_name"];

$buffer_size = 4096;
$out_file_name = str_replace('gz', '', $file_name);

$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb');

if($file != false)
{
    while (!gzeof($file)){
        fwrite($out_file, gzread($file, $buffer_size));
    }
}
else{
    print("Attention problem file false");
}


fclose($out_file);
gzclose($file);

// $_FILES["file"]["name"]

if (unlink("C:\\tmplog\\".$_FILES["file"]["name"]. "/user.log")) {
    // file was successfully deleted
  } else {
    // there was a problem deleting the file
  }
  sleep(2);
  $find_str = 'total size is';
  $fp = @fopen($_FILES["file"]["tmp_name"], "r");
  if ($fp) {
      while (($line = fgets($fp,)) !== false) {
          if ( strpos($line, $find_str) !== false ) {
              $keep_for_later = $line;
          }
      }
      fclose($fp);
  }



print($keep_for_later);
if (!file_exists('C:\tmplog')) {
    mkdir('C:\tmplog', 0755, true);
}

if (!file_exists("C:\\tmplog\\".$_FILES["file"]["name"])) {
    mkdir("C:\\tmplog\\".$_FILES["file"]["name"], 0755, true);
}

$dir = "C:\\tmplog\\".$_FILES["file"]["name"];
file_put_contents($dir ."/user.log", $keep_for_later);




$array = array();
$value = preg_match("/(\d*,\d*|\d+)/",$keep_for_later, $array);
print_r($array);

if($array){
    $teste = $array[0];
    $testa = str_replace(',','', $teste);
    if(is_numeric($teste)){
        $teste = $testa;
    }
    
    
    if ($testa >0) {
        print("Succes: la taille du fichier est de: " .$array[0]);
    }
    else if ($testa == 0) {
        print("Error");
    }
    else{
        print("Warning: the size is: " .$array[0]);
    }
}
else
{

}


$dir = "C:\\tmplog\\".$_FILES["file"]["name"];
file_put_contents($dir ."/result.log", $array);

我从Curl命令中得到了这个文件:

curl -F 'file=@logbackup-infitarif.gz'  http://mylink/projet/index.php

它在Linux上运行.

有什么主意吗? Thanks if so!

推荐答案

That is saying the total size is was not found.
Is the case correct? Like is Total capitalized?
strpos is case sensitive. stripos is not.

$keep_for_later设置为取消链接行上方的值.

$keep_for_later = 'Not Found';
if (unlink("C:\\tmplog\\".$_FILES["file"]["name"]. "/user.log")) {

Php相关问答推荐

允许Laravel路由指定`withTrashed`,尽管有显式的模型绑定

致命错误:无法使用简单的php博客重新声明spl_autoload_Register()

将产品类别添加到WooCommerce产品附加信息

Php解压缩deflate64

允许在WooCommerce管理员优惠券列表中显示自定义优惠券类型

WooCommerce HPOS管理订单列表中带有订单元数据的定制列

从AJAX响应中获取一个未定义的html

使用与OpenSSL命令行兼容的AES-256-CTR为大型文件创建php代码OpenSSL加密

Select 本地提货时隐藏WooCommerce显示的发货成本

表单提交返回空白页

以编程方式同步 WPML 翻译更改 Woocommerce 产品销售价格

将可编辑的计费自定义字段添加到 WooCommerce 管理单个订单

当未 Select 任何变体时,在 WooCommerce 可变产品上显示自定义文本

有没有办法获取触发流操作的页面的 URI?

标签打印机的 CSS

图片上传成功

使用产品自定义字段作为 WooCommerce 中特定用户角色的折扣百分比

在 Botiga 主题模板中添加复选框到政策行.Woocommerce

如何在构建 PHP 类别数组树的递归函数中将父面包屑传递给子项?

我怎样才能在 .htaccess 中有 2 个参数?