How can I extract attachment from an xml file? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How can I extract attachment from an xml file?

Last post 11-02-2017 07:14 AM by rajkumar.bathula. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 06-24-2008 10:58 AM

    How can I extract attachment from an xml file?

    How can I to extract attachment (picture or file attachement*base64) from an XML file (infopath) to a local file. I prefor to  use C#. Thank you.

  • 06-24-2008 11:31 AM In reply to

    Re: How can I extract attachment from an xml file?

    Hello:

    I've done this with an open InfoPath form, connected to the Changed event on a picture control using the following code:

    string time = DateTime.Now.ToString("ddMMyyyyhhmmss");
    string fileName = selectedField + time;
    byte[] data = Convert.FromBase64String(picBase);

    //write the file
    FileStream outFile = new FileStream(path + fileName + ".jpg", FileMode.Create, FileAccess.Write);
    outFile.Write(data, 0, data.Length);
    outFile.Close();

    Where selectedField is a string value from a node in the form, and path is the file path. I'm not sure how this would work with a file -- I'm also not sure how to get the extension of any file  that may be attached, but it might get you started.

    Hilary Stoupa

  • 06-25-2008 07:21 AM In reply to

    Re: How can I extract attachment from an xml file?

    Hello:

    I was reminded by someone else that these attachments have a header that you can use to get the name of the file. Please see this helpful blog post for more information: http://chrissyblanco.blogspot.com/2006/07/infopath-2007-file-attachment-control.html

    Hilary Stoupa

  • 06-26-2008 08:15 AM In reply to

    Re: How can I extract attachment from an xml file?

    Thank you very much.
  • 06-27-2008 09:34 AM In reply to

    Re: How can I extract attachment from an xml file?

     I' ve already  extracted attachment file to local file successfully, But i must know the atachment file type at first. 

    However, user  will upload .doc file or .pdf file or others type , How can i got the file type?

  • 06-27-2008 10:49 AM In reply to

    Re: How can I extract attachment from an xml file?

    Hi:

    That information is in the file header. In the post at http://chrissyblanco.blogspot.com/2006/07/infopath-2007-file-attachment-control.html about halfway down the code, the author pulls the file name from the attachment and converts it from bytes to a string. When I tried using this code (modifying only the location it saves a file to, adding a message box to show me the file name variable, and fixing one issue) the fileName variable included the file extension.

    The modification I made was to change this:

    // The actual filename starts at position 24 . . .
    for (int i = 0; i <>
    {
        fnBytes[i] = attachmentNodeBytes[24 + i];
    }

    to this:

    // The actual filename starts at position 24 . . .
    for (int i = 0; i < fnLength; ++i)
    {
         fnBytes[i] = attachmentNodeBytes[24 + i];
    }

    since the for condition was not complete (and, of course, <> is not a valid C# operator).

    Hilary Stoupa

  • 09-11-2008 01:51 PM In reply to

    Re: How can I extract attachment from an xml file?

     Hi,

     is it possible to extract attachment from browser-enabled form to avoid sync form from server to client's browser? when I use InfoPath 2007 to store attachment into my form the is no network traffic from server to infoPath 2007 after I clicked Attach. When I use the same form with IE after saving attachment to the server I see network traffic back to my client's browser - InfoPath Forms Services sync loaded form with with one in my browser.

     I investige structure of webpage showing my form and found some variable (javascript) which contains all form's data !

    How to avoid sync form after loading attachment to the server?

     Regards,

    Robert

  • 01-15-2009 12:04 PM In reply to

    How to Extract Attachment from Infopath Forms in javascript?

    Please reply ASAP if ypou know.

    BMK
  • 11-02-2017 07:14 AM In reply to

    Re: How can I extract attachment from an xml file?

    Hello, I am looking for solution to read the user attached file (usually JPEG, PNG ) from the form and compress it (to reduce file size) and then placing these compressed files instead actual files that user attached. Mine is a browser enabled form. Please advice if we can achieve it. I have code behind option enabled for my form. So i can use c# code to compress the attachments.
    Thank you
    Raj
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.