Monday, July 27, 2009

How can I populate an HTML form from a desktop application?

Hey all you smart developers…question for ya! I have a project and I need some feedback on feasibility. I am designing a web page to facilitate document sharing from a Windows desktop application. Here is the scenario I am trying to make work:


1) User creates document from desktop application and saves it to a location on their local file system


2) With the saved document open, user clicks button within the application to “share document”


With me so far? Here’s where it gets a little screwy…


3) Clicking the “share document” launches a web browser and populates a file path input field (input type="file") with the path of the saved document. For example: c:\document.txt would be automatically passed to the HTML input field eliminating the need to browse for the file path.





I realize this isn't an elegant way to upload (ideally, we'd send it directly from the desktop app using an upload API) but we have some constraints. Can it be done as described above? If so, how?

How can I populate an HTML form from a desktop application?
Possibly. How I would do it, would be to have this desktop application to launch an HTML file with a preset value of the saved document location in the %26lt;input type="file" value="C:\path\to\file.ext"%26gt; Unfortunately, Internet Explorer and Netscape(The gecko engine which powers Mozilla and Firefox) do not use the VALUE attribute as the default contents of the input area. Any default value set via HTML is not usable via scripting and the DOM as well (hence it is not listed as 'supported' in any of the browsers.) If a user enters text in the field however, that value is then reachable via the DOM as it normally would be for a normal INPUT field (via the .value property.) The reason for this behavior would presumably be to ensure the security/safety of users against malicious authors. Opera displays the default VALUE attribute value and submits it as well (although it prompts for confirmation on submit if you have not altered that value.)





If there is a way, I'd love to hear it. I just ran some tests, and have not been able to use the %26lt;input type="file" value%26gt; method. Perhaps what you could do, is instead of "file", use "hidden", and have it automatically upload through an server side upload script with the path to the file from the hidden value, rather than a user inputted file value?
Reply:Go to Dreamweaver!

covent garden

No comments:

Post a Comment