【问题标题】:Private function including variables包含变量的私有函数
【发布时间】:2018-07-05 07:26:56
【问题描述】:

我正在尝试将Crop-avatar 包含到我正在修复的一个小项目中。

我已经包含了这些文件,它可以上传并且看起来不错,但是我无法在包含脚本中包含 $_GET 变量。我猜它与代码使用的“私人功能”有关。

网址如:index.php?id=12345

<?php
include("Crop.php");

class CropAvatar
{
    private $src;
    private $data;
    private $dst;
    private $type;
    private $extension;
    private $msg;

    private function setDst()
    {
        $this->dst = 'images/' . date('YmdHis') . '.png';
    }
}

https://github.com/fengyuanchen/cropper/blob/master/examples/crop-avatar/crop.php

我想改变这个:

$this->dst = './images/' . date('YmdHis') . '.png';

到这样的事情:

$this->dst = './images/' . $trimmeduserid . '.png';

关于如何解决此问题的任何提示或方向?

问候, 一月

【问题讨论】:

  • 代码太多。请提供重现您的问题所需的最少代码。删除与问题无关的所有内容。
  • 谢谢,现已更新。
  • 你不能用post吗?

标签: php function private


【解决方案1】:

应该很简单:

// Change
$this->dst = 'images/' . date('YmdHis') . '.png';

// to
$this->dst = 'images/' . trim($_GET['id']) . '.png';

【讨论】:

  • 我是这么想的,但后来它只是将文件重命名为 .png
  • 如果您在 $_GET 数组中没有 ID,那么您没有问题描述的 URL
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-22
  • 1970-01-01
  • 2013-08-19
  • 2013-08-02
  • 2014-07-13
  • 2013-01-22
  • 1970-01-01
相关资源
最近更新 更多