Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:51:51+00:00 2026-05-27T04:51:51+00:00

I am using the jQuery Webcam Plugin with this code: $(#camera).webcam({ width: 250, height:

  • 0

I am using the jQuery Webcam Plugin with this code:

$("#camera").webcam({
            width: 250,
            height: 375,
            mode: "save",
            /*swffile: "js/jscam_canvas_only.swf",*/
            swffile: "js/jscam.swf",
            onTick: function(remain) {
                if (0 == remain) {
                    jQuery("#status").text("Cheese!");
                } else {
                    jQuery("#status").text(remain + " seconds remaining...");
                }
            },
            onSave: function () { },
            onCapture: function () {
                webcam.save('/upload.ashx');
            },
            debug: function () { },
            onLoad: function () { }
        });

The plugin uses PHP like this:

<?php
    $str = file_get_contents("php://input");
    file_put_contents("/tmp/upload.jpg", pack("H*", $str));
?>

and my upload.ashx :

public void ProcessRequest(HttpContext context)
{
    System.IO.Stream str = context.Request.InputStream;
    int strLen = Convert.ToInt32(str.Length);
    byte[] strArr = new byte[strLen];
    str.Read(strArr, 0, strLen);

    //string st = BitConverter.ToString(strArr); // try 1
    //string st = BitConverter.ToString(strArr).Replace("-",""); // try 2
    //string st = ByteArrayToString(strArr); //try 3
    string st = String.Concat(Array.ConvertAll(strArr, x => x.ToString("X2"))); // try 4
    File.WriteAllText(context.Server.MapPath("~/img/Webcam" + DateTime.Now.Ticks.ToString() + ".jpg"), st);
}

public static string ByteArrayToString(byte[] ba)
{
    StringBuilder hex = new StringBuilder(ba.Length * 2);
    foreach (byte b in ba)
        hex.AppendFormat("{0:x2}", b);
    return hex.ToString();
}

I also tried to read the byte array to the Bitmap object and save that to the disk, but that also does not work. I am really missing something here…

Edit Thanks Onkelborg,

I forgot to mention that the code does not give errors, it saves files. But the images are corrupted. Can’t view them in Windows Photo Viewer or Adobe Photoshop.

Edit2 this also does not work. (also corrupt images)
Save Image From Webrequest in C#

Edit3 I use this to convert the string to high nibble first hex:

    public static byte[] ToHexByte(byte[] arstr)
    {
        byte[] data = new byte[arstr.Length];
        int end = arstr.Length;

        for (int i = 0; i < end; i++)
        {
            byte ch = arstr[i];
            byte highNibble = (byte)((ch & 0xf0) >> 4);
            byte lowNibble = (byte)((ch & 0x0f) << 4);
            data[i] = (byte)(highNibble | lowNibble);
        }
        return data;
    }

Edit4

I found this resource http://www.kirupa.com/forum/showthread.php?300792-XML.sendAndLoad%28%29-not-working-IIS7.-ASP.Net-2.0-%28C-3.0%29
and set ValidateRequest="false" in my page directive. found that because i found line 183 from https://github.com/infusion/jQuery-webcam/blob/master/src/jscam.as
i have the feeling that i am getting closer now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:51:52+00:00Added an answer on May 27, 2026 at 4:51 am

    The answer is: http://code.google.com/p/jpegcam/
    because it is hard to find out how to decode the bytes you receive from the flash file.

    Now I just needed two lines of Asp.Net C# code in my *.ashx file:

    byte[] data = context.Request.BinaryRead(context.Request.TotalBytes);
    
    File.WriteAllBytes(context.Server.MapPath("~/img/cam" + DateTime.Now.Ticks + ".jpg"), data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this jQuery plugin: http://www.xarg.org/project/jquery-webcam-plugin/ When I run this code on localhost ,
Using jQuery 1.5.1 Tried this block of code in: head section as well as
using jQuery I have the following code: var selectedIdsArray = $(#selectId option:selected).map(function(){return this.value;}); var
Using jquery how do i simply check if it is read only? this is
Using jQuery, what's the best way to automatically initialize a plugin on all current
Using jQuery I want to give a specific element the same width (or min-width
Using jQuery validation plugin but it has no CSV validation. I have made an
Using jQuery 1.7.2 $(function(){ $('#parentElem').mouseenter(function(){ $('.myElem').animate({opacity:1}, 'fast'); }).mouseleave(function(){ $('.myElem').stop().animate{opacity:0}, 'slow'); }); }); In this
I donwloaded this small sample for jquery http://plugins.jquery.com/project/WebcamQRCode it is a plugin for a
Using jQuery UI , I have a tabs plugin and within tab 1 gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.