【问题标题】:PHP notice: Undefined index: idOrAttributeName_xPHP 通知:未定义索引:idOrAttributeName_x
【发布时间】:2012-09-26 13:16:27
【问题描述】:

PHP 通知:未定义索引:idOrAttributeName_x

我在 yii 框架中使用 jcrop 扩展。当时我收到了这个通知。我正在使用 yii 框架开发一个网站,在其中我有一个裁剪图像的任务。对于这个任务,我在 yii 框架中使用 Jcrop 扩展. 当我将以下给定代码添加到我的控制器操作 index() 方法时,我得到了这个错误。实际上我不知道在函数中传递哪个变量。

Yii::import('ext.jcrop.EJCropper');
$jcropper = new EJCropper();
$jcropper->thumbPath = '/my/images/thumbs';

// some settings ...
$jcropper->jpeg_quality = 95;
$jcropper->png_compression = 8;

// get the image cropping coordinates (or implement your own method)
***$coords = $jcropper->getCoordsFromPost(**'idOrAttributeName'**);***

// returns the path of the cropped image, source must be an absolute path.
$thumbnail = $jcropper->crop('/my/images/imageToCrop.jpg', $coords);

我是 yii 框架的新手,请帮助...

【问题讨论】:

  • 请提供扩展的链接
  • 我以前没有使用过那个扩展,但看起来getCoordsFromPost() 方法正在你的 POST 数组中寻找一个属性。如果您将idOrAttributeName 更改为您发布的文件的名称可能会有所帮助?

标签: php jquery yii


【解决方案1】:

好的,问题是 jcropper 会寻找“POST”值来检测在哪里进行裁剪(x、y、高度和宽度)。为了提供它们,您必须像这样编码发送它们 “somestring_x”、“somestring_y”、“somestring_h”和“somestring_w”。

在这种情况下,'somestring' 正是您在 getCoordsFromPost 方法中输入的内容:在您的情况下为 "idOrAttributeName"。

如果你看一下github上的源代码就会清楚(确实很简单)。

【讨论】:

    猜你喜欢
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2011-02-10
    相关资源
    最近更新 更多