0

<script language="JavaScript"> webcam.set_api_url( 'test.php' ); webcam.set_quality( 90 ); // JPEG quality (1 - 100) webcam.set_shutter_sound( true ); // play shutter click sound </script>

我在我的网站上尝试 jpegcam(我使用 codeigniter)。我无法加载我的 webcam.swf 或 webcam.php 或 test.php。我如何在 javascript 中访问 php 在 codeigniter 中锁定这个?

当我刷新我的网站时,那里无事可做,但是当我尝试 jpegcam(没有 codeigniter)时,它运行良好。对不起我的愚蠢问题,我是codeigniter的新手,

<table><tr><td valign=top>
<h1>JPEGCam Test Page</h1>

<!-- First, include the JPEGCam JavaScript Library -->
<script type="text/javascript" src="webcam.js"></script>

<!-- Configure a few settings -->
<script language="JavaScript">
    webcam.set_api_url( 'test.php' );
    webcam.set_quality( 90 ); // JPEG quality (1 - 100)
    webcam.set_shutter_sound( true ); // play shutter click sound
</script>

<!-- Next, write the movie to the page at 320x240 -->
<script language="JavaScript">
    document.write( webcam.get_html(320, 240) );
</script>

<!-- Some buttons for controlling things -->
<br/><form>
    <input type=button value="Configure..." onClick="webcam.configure()">
    &nbsp;&nbsp;&nbsp;
    <input type=button value="Take Snapshot" onClick="webcam.snap()">
</form>

<!-- Code to handle the server response (see test.php) -->
<script language="JavaScript">
    webcam.set_hook( 'onComplete', 'my_completion_handler' );

    function my_completion_handler(msg) {
        // extract URL out of PHP output
        if (msg.match(/(http\:\/\/\S+)/)) {
            var image_url = RegExp.$1;
            // show JPEG image in page
            document.getElementById('upload_results').innerHTML = 
                '<h1>Upload Successful!</h1>' + 
                '<img src="'+image_url+'">';
        }
        else alert("PHP Error: " + msg);
    }
</script>

</td><td width=50>&nbsp;</td><td valign=top>
    <div id="upload_results"></div>
</td></tr></table>

请帮助我,非常感谢

4

1 回答 1

0

Use the base_url function of the URL Helper (http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html) to load your assets file and controller.

For example:

echo base_url("path/to/webcam.swf");
echo base_url("path/to/webcamuploadhandler/controller");

I think you also need to set the set_shutter_sound to load the appropriate .mp3 file, something like this in your view file:

webcam.set_shutter_sound(true, "<?php echo base_url("path/to/shutter.mp3"); ?>");

Furthermore, since you use a framework, I guess you have to set response Content-type of the webcamuploadhandler/controller as "text/plain". There is an issue I experienced lately: http://code.google.com/p/jpegcam/issues/detail?id=15

于 2013-02-28T03:42:08.143 回答