• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Capture image with webcam using flash and sending it to the server

Explorer ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

I have a need to use flash to capture an image and have that image uploaded to the server. I have seen some examples of code that uses flash to capture an image but it saves the file locally. We need that file to be sent to the server. We are using CF9.0 and I figure that once we are able to capture the image we could hand it off to ColdFusion to send to the server.

Has anyone done anything like that or know if it's possible?

Any help is apprecaited.

Thanks,

Mallory

TOPICS
Flash integration

Views

2.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 05, 2010 Oct 05, 2010

Copy link to clipboard

Copied

Unless you plan to have people with some type of camera or other standing around your server room, what ever you do will need to save the image capture locally, and THEN send it to the server where it could easily be processed by ColdFusion CFML code.

Can't offer any insight into actual code or tools, but I wanted to clarify the client - server relationship and what each piece does that many (especially new) developers overlook.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 06, 2010 Oct 06, 2010

Copy link to clipboard

Copied

LATEST

It's not that hard...after you capture the image in Flash encode just send it via Remoting to a cfc as a bytearray or a bytearray encoded as Base64 string (and then decode it to binary in the CFC). I have had better luck with the latter way. You could also post the bytearray encoded as a Base64 string to a .cfm page as a form field.

For example in Action Script 3 you do something like this (assuming "frameBMD" is the BitmapData drawn from the video source):

var ba:ByteArray=com.adobe.images.PNGEncoder.encode(frameBMD);

var baAsString:String=com.dynamicflash.util.Base64.encodeByteArray(ba);

//

var saveImageResponder:Responder=new Responder(onSaveImageResult,onFault);

var rs=new NetConnection();

rs.objectEncoding=flash.net.ObjectEncoding.AMF3;

rs.connect("/flashservices/gateway");

rs.call("Headshot.saveImage",saveImageResponder,baAsString,1);

And your cfc would be something like this:

<cfcomponent displayName="Headshot" hint="Save a Headshot">

<cffunction name="saveImage" access="remote" output="false" returntype="string" roles="user">

  <cfargument name="data" type="string" required="true" />

  <cfargument name="user_id" type="numeric" required="no" default="1">

  <cfset SavePathParent = ExpandPath("/data/users")>

  <cfset SavePath = SavePathParent & "/user_" & arguments.user_id>

  <cfif NOT DirectoryExists(SavePath)>

    <cfdirectory action = "create" directory = "#SavePath#" mode="777">

  </cfif>

  <cfset theFilePath="#SavePath#/headshot_#arguments.user_id#.png">

<!--- Write the file --->

  <cffile action="write" file="#theFilePath#" output="#toBinary(arguments.data)#"/>

  <cfset LOCAL.file_url="/data/users/user_#arguments.user_id#">

  <cfreturn LOCAL.file_url/>

</cffunction>

</cfcomponent>

Anyway, that's the idea... hope that helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation