douzuizhuo0587 2019-02-26 18:48 采纳率: 0%
浏览 101


I hope you can help me on this matter. I tested a very simple script to add a comment to a zip file before downloading it, and it worked fine, so now I decided to try implementing it into a file hosting script, but I'm being unable to find a way to edit the generated file.

At line 59 of this file: (which is the file which generates the download link for my file) you can see my edit, which I will also post below:

$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
    $ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
    $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
    $ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
    $ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
    $ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
    $ipaddress = getenv('REMOTE_ADDR');
    $ipaddress = 'UNKNOWN';

# Create a new Archive
$zip = new ZipArchive;
# Create the file to archive to
$res = $zip->open($file, ZipArchive::CREATE);
# If create works
if ($res === TRUE) {
    # Create the comment here

Basically it works to append the IP of who downloads it into the zip file, as comment.

As standalone script it works fine, but I'm having a hard time implementing it into the file hosting script, as when the file gets downloaded, it's unmodified.

I suppose the problem is with the variable $file which might not be correct, because as stand-alone script it's enough to specify in there the name of the archive in order to append the comment and then download it, while with the file hosting script, if I assign the variable holding the file name (which is $file->originalFilename), still nothing happens.

Hope you can assist me into properly implementing my script, thank you.

  • 写回答



      相关推荐 更多相似问题


      • ¥15 Halcon 曲线拟合时怎么过滤掉异常点
      • ¥15 edge浏览器最近莫名其妙老是每隔一段时间弹出色情网站,求解决。。
      • ¥15 “glmnet”运行出错
      • ¥30 如何用matlab表达以下公式?
      • ¥15 在arm架构芯片上基于32位linux操作系统做内存检查
      • ¥15 怎么样才能禁止VS自动调整Windows窗体布局
      • ¥15 mysql5.7.40安装到Initializing database报错,如何解决?
      • ¥30 如何降低hdfs中datanode的JVM内存用量
      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥40 Hive SQL数据查询,子查询