【问题标题】:Yii webcam extensionYii 网络摄像头扩展
【发布时间】:2014-06-18 05:41:28
【问题描述】:

在 Yii 中,我使用 yii-jpegcam 网络摄像头扩展用于在我的应用程序中拍照,它适用于以下 url 格式

index.php?r=user/newphoto

但我的应用程序是“/”格式(index.php/user/newphoto)。所以这个扩展不适用于我的 url 格式。怎么解决?

 Extension Link used : http://www.yiiframew...on/yii-jpegcam/
http://www.yiiframework.com/extension/yii-jpegcam/

我的视图代码是:

<?php $onBeforeSnap = "document.getElementById('upload_results').innerHTML = '<h1>Uploading...</h1>';";
      $completionHandler = <<<BLOCK
        if (msg == 'OK') {
            document.getElementById('upload_results').innerHTML = '<h1>OK! ...redirecting in 3 seconds</h1>';

            // reset camera for another shot
            webcam.reset();
            setTimeout(function(){window.location = "index.php?r=user/index";},3000);
        }
        else alert("PHP Error: " + msg);
BLOCK;
      $this->widget('application.extensions.jpegcam.EJpegcam', array(
            'apiUrl' => 'index.php?r=user/jpegcam.saveJpg',
            'shutterSound' => false,
            'stealth' => true,
            'buttons' => array(
                'configure' => 'Configure',
                'takesnapshot' => 'Take Snapshot!'
            ),
            'onBeforeSnap' => $onBeforeSnap,
            'completionHandler' => $completionHandler
        )); ?>

【问题讨论】:

    标签: php yii webcam yii-extensions yii-components


    【解决方案1】:

    如果 urlManager 在配置中启用,您应该使用 createUrl 方法更改 apiUrl 值:

    $this->widget('application.extensions.jpegcam.EJpegcam', array(
            'apiUrl' => Yii::app()->urlManager->createUrl('index.php/user/jpegcam.saveJpg'),
            'shutterSound' => false,
            'stealth' => true,
            'buttons' => array(
                'configure' => 'Configure',
                'takesnapshot' => 'Take Snapshot!'
            ),
            'onBeforeSnap' => $onBeforeSnap,
            'completionHandler' => $completionHandler
        ));
    

    【讨论】:

    • 对不起,您是否也尝试更改此行中的 url:setTimeout(function(){window.location = "index.php?r=user/index";},3000);跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 2020-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多