locked
Saving images in a site's folder and passing their paths as string values RRS feed

  • Question

  • Hi everyone!
    The big picture of my situation is:
    Using a webcam I must take 5 snapshots and save them in a server/site's folder, and finally get their paths 
    (from de root folder of the site) as string values to use them saving a record in a table of a MySQL Database.
    I've been looking for information around the Internet about how to implement it. I use Visual Studio 2010, C# and .NET Framework
    3.5 for the ASP.NET Website. NOTE: I'm building the Silverlight component in SL4.
    I already read/watched these articles:
    Accessing Web Camera and Microphone: http://www.silverlight.net/learn/videos/all/access-web-camera-microphone/
    Capturing the Webcam in Silverlight 4: http://www.silverlightshow.net/items/Capturing-the-Webcam-in-Silverlight-4.aspx
    I'm novice using Silverlight and I really would appreciate any suggestion, link or help you can give me :)
    To summarize I need help with:
    How to save the shapshots to the server?
    How to pass the string values of images' path to a control or controls in a webform (.aspx)?
    Thanks in advance!!!

    Hi everyone!

    The big picture of my situation is: Using a webcam I must take 5 snapshots and save them in a server/site's folder, and finally get their paths (from de root folder of the site) as string values to use them saving a record in a table of a MySQL Database.

    I've been looking for information around the Internet about how to implement it. I use Visual Studio 2010, C# and .NET Framework 3.5 for the ASP.NET Website. NOTE: I'm building the Silverlight component in SL4.

    I already read/watched these articles:

    • Accessing Web Camera and Microphone: http://www.silverlight.net/learn/videos/all/access-web-camera-microphone/
    • Capturing the Webcam in Silverlight 4: http://www.silverlightshow.net/items/Capturing-the-Webcam-in-Silverlight-4.aspx

    I'm novice using Silverlight and I really would appreciate any suggestion, link or help you can give me :)

    To summarize I need help with:

    1. How to save the shapshots to the server?
    2. How to pass the string values of images' path to a control or controls in a webform (.aspx)?

    Thanks in advance!!!

    Monday, May 30, 2011 10:51 PM

Answers

  • http://www.silverlightshow.net/items/Capturing-the-Webcam-in-Silverlight-4.aspx has webcam capture in SL. So, what you need is to get this image to the server, Right?

    The image should be converted to byte and send it to the service..

    Here is a sample code

    byte[] byteBuffer = ConvertImageToByte(); // Use your logic to convert bitmap to byte...
    public string SaveImage(byte[] uploadedFile)
    {
    string completeFilePath = string.Empty;
    string filePathInServer = ConfigurationManager.AppSettings["FilePathInServer"] + fileName;
    if (uploadedFile != null)
                {
    // Maybe some logic to get the file path in the server... Say Server.MapPath... or hard coded path in the server.. whatever you wish
                    completeFilePath = GetCompleteFilepath(filePathInServer);
                    FileStream fileStream = new FileStream(completeFilePath, FileMode.Create, FileAccess.Write);
                    fileStream.Write(uploadedFile, 0, uploadedFile.Length);
                    fileStream.Close();
                    fileStream.Dispose();
                }
    }
    


    Make sure that you are setting the web config for the web service to accept file with more size!

    Monday, May 30, 2011 11:09 PM