Hopefully someone will be able to assist.
I am creating an online submission form in HTML, with the ability to add upload an attachment. The resulting data ends up in a Notes / Domino database.
I have managed to get the HTML form working, with the upload button. However, when viewing the received data, instead of having an attachment in the rich text field of the Notes form, I end up with the contents of the attachment. This is fine where it is a text document. However, when it is a Word / Excel doc, it ends up as a load of gibberish.
Can anyone suggest what is wrong ?
Here is my code :
<form method="post" enctype="multipart/form-data" action="/webquote.nsf/gendoc?createdocument" >
Attachment: <Input Type="file" NAME="Attachments" MAXLENGTH=50 ALLOW="text/*" >
Thanks,
Simon
Here are two lines of code from a production database I built a while ago:
<form name="SubmissionForm" id="SubmissionForm" action="/<Computed Value>/AgencySubmission?CreateDocument" method="post" enctype="multipart/form-data">
<input type="file" name="%%File.1">
It works for me. It may not be exactly what you look for, the file is not attached into a Rich Text field, but you can always detach are re-attach it on the server after submission.
I have also built file uploads using jQuery and Ajax, so the page does not have to be reloaded.
The prefered way for this kind of stuff nowadays would be to directly design an xPage. Does that seem doable, or do you have some constraints, like the HTML being designed somewhere else and the integration with Domino later, almost at last resort ?
From the look of your <input> it would look like we are in the later situation.
What's with the "allow" attribute ? I can't find any reference. Did you mean "accept" ? And what about the value of "text/*" ? This could be the source of the giberish, as the browser and/or Domino would interpret the input as text rather than a blob. A value of "multipart/form-data" would perhaps be more appropriate, but no "allow" or "accept" attribute at all works fine too.
For some reasons, Domino being Domino, the "name" attribute of your <input> element must be "%%File.1", in short simply
<input type="file" name="%%File.1">
Your <form> element is spot on.
The last thing to worry about is that your Domino server will see the file comming out of seemingly nowhere and balk with an error 500 "HTTP Web Server: File Upload Not Allowed Exception". You'll need to talk to your Domino admin and have him set the following parameter in the server's notes.ini :
DominoDisableFileUploadChecks=1
Then you're all set.
Hope this helps.
Create a Notes Form (a Form design element), add a File Upload control.
Add a Web Query Save agent (see Form design ouline).
In that agent, get the NotesDocument notessession.documentContext
This will contain the content of your uploaded file, and any other field son your Form, split into Notes items.
You can get the attached file with notesdocument.embeddedobjects to locate all attachments, and/or notesdocument.getAttachment (if you know the filename).
That's perhaps the oldskool way of doing it, but it's tried & tested, and what Domino is expecting you to do.
Related
I am unsure if this is possible...I am currently working on a VBS script which fills in a web form and uploads a file. However, the upload button is a HTML input field of type "text"...The way I am planning to approach this is to remove the attribute type="file" and replace it with type="text". Then I am planning to populate the resulting text box with my file location and click upload afterwards. This works great when done manually through the browser developer tools.
However, I am limited to use of VBScript as the solution must be supportable by my colleagues. Has anybody got any ideas?
With some determination I stumbled through and produced an answer to my own Question:
IE.Document.All.Item("testYOYO").type = "text"
IE.Document.All.Item("testYOYO").value = "testtest"
You can try:
IE.Document.getElementsByClassName("testYOYO").Item(1).removeAttribute(the Attribut)
Good Luck
I'm trying to embed a value into the textbox at the USCIS government website to check my application status number. Suppose it's LIN1234. After inspecting the element of the webpage I see that the HTML wrapper for the textbox is:
<input id="receipt_number" name="appReceiptNum" class="form-control textbox initial-focus" maxlength="13" type="text">
I tried opening up this URL with a suffix added on, but to no avail:
https://egov.uscis.gov/casestatus/landing.do?receipt_num=LIN1234
Is there a way to to this?
Before that, you must understand what means adding ?receipt_num=LIN1234 to the url.
When sending a request (By default and in this context) from your browser, it'll be a GET request (see here) where you send as a get argument your receipt number, setting its key to receipt_num.
What is done to this data on the server side, however, is up to itself.
Just understand that unless the server is made to auto-fill the field with that value in case it receives it, it won't do anything except sending some more data.
I think you want to load this page in your browser with auto-filled field.
In that case you should look into extensions for your browser that would do that automatically.
You probably won't be able to embed a value into the textbox... Just because you are sending values by GET (which is what the landing.do?receipt_num=LIN1234 syntax is doing) doesn't mean that they have something set up to process it, so the GET variable will probably not do anything.
You might be able to see how their URLs work ordinarily, what the page URL that you are aiming to land on looks like, and either decode something from that or set a bookmark there. That said, if they are submitting that data via POST (which they probably are, for security reasons), that probably won't work.
I would suggest looking at reputable form-filling plugins for your web browser, if that's an option. That might allow you to work around that.
My application basically converts images. When uploading an image, it is processed at the server and the server sends the result back as an attachment, which results in an immediate download.
It already works with a plain HTML form, such as
<form action="/icon" method="post" enctype="multipart/form-data">
<input type="file" name="image"/>
<input type="submit" value="Create"/>
</form>
The server responds with header Content-Disposition=attachment; filename=\"processed.zip\" etc.
Of course, the stock <input type="file"...> has a very ugly look and I'd like to give it a different styling. Additionally, in order to improve user experience, I'd like to support drag & drop for file upload.
However, all file upload frameworks or just plain JavaScript based drag & drop only supports "AJAX"-like uploads (using XMLHTTPRequest). Then, however, the immediate download doesn't work.
Is there any way, a trick, a solution for this?
Until now I found only the following solution. It involves a JavaScript framework, Dropzone.js, but would work with any other JavaScript implementation.
Handle drag & drop and upload with JavaScript
Server returns the zip file in Base64 encoding
Create a data: URI
Create with JavaScript create a temporary <a> element and perform a click event (as described in this StackOverflow answer)
This solution only works, because the result is smaller than 32 KB. In Google Chrome and Firefox, the download even has an adequate filename. In Safari unfortunately it doesn't work.
I am learning html from w3schools. They have used <form action="demo_form.asp"> this form tag with attribute action="demo_form.asp. I know the meaning of form tag as well as action attribute. But I don't know what is the meaning of action="demo_form.asp". When I use this attribute action="demo_form.asp", a file named demo_form.asp start downloading!
Can anybody explain me this thing?
Full code is here.
action attribute define the page to be use to post the data, when you hit submit button it redirect to the page you have mentioned in the action attribute. so that you can access the data submitted through this page.
The action="demo_form.asp" attribute is the file to which your <form> will be submitted.
From HTML spec
action = uri [CT]
This attribute specifies a form processing agent.
It's used to send the request to the page (url) specified in the action attribute when the form is submitted.
As per the example:
Once you enter your favourite color in the input box & click submit.
The form details is sent to the server page (demo_form.jsp) based on form action.
There the form is processed and based on the input, it's redirecting you to different page.
Where you can find the fav color which you have entered is mentioned there.
Input was received as:
favcolor=blue
The value of the action attribute tells the browser the location of the script that will process this form. In the example you have provided, the data submitted by the user in the form will be processed by the file/script called demo_form.asp.
The action element points to a thing that will handle the content of the form you have submitted. This can be as simple as a new page (maybe php), or a .cgi script, and so on. In your case it is attempting to submit to an ASP page. If you are attempting to use the form in your own pages, it is likely your browser can't find 'demo_form.asp'.
Why it is attempting to download it, rather than just tell you the page is missing, I'm afraid I don't know.
Hope this helps.
demo_form.asp should execute and not download. How are you running the file? It looks like your IIS is not enabled.
If you are trying this locally, to run ASP you'll have to configure IIS in your system (it is not enabled by default) and then use
http://localhost
.... to run your file. Otherwise ASP will not execute. See http://msdn.microsoft.com/en-us/library/ms181052(v=vs.80).aspx for enabling IIS. Once IIS is enabled,
http://localhost
will point to c:\inetpub\wwwroot folder by default. Create a folder in wwroot (say test) and place your files inside that folder. If your file is abc.asp then to run it you'll have to type
http://localhost/test/abc.asp
.
Hope this helps.
I'm sure I'm missing something basic here, but I just can't get my finger behind it..
If I land on a url that is say domain.com?key=123 and there is a form on domain.com that has a field called key. I thought it would fill in that field with the value 123 by itself, since it's been passed. Am I missing something here?...
thank you!
The webmaster may decide to pass the variable inside of the html form, but that may also be not the case. Most often, GET requests are used to send data from a form to a php script but it's more rare to see the an html form compiled with a php script.
If you want a form field that pulls in your URL parameters then do something like this:
PHP
<label>Key:</label>
<input type="text" value="<?php echo $_GET["key"]; ?>">
Coldfusion
<label>Key:</label>
<input type="text" value="<cfoutput>#URL.key#</cfoutput>">
What language are you using? Normally you start with a question mark...
domain.com/?key=123
If you have other variables you use an ampersand.
domain.com/?key=123&anotherKey=456&lastKey=789
UPDATED: Here is a link to parse the query string using Javascript:
How can I get query string values in JavaScript?
Something else happens on that page - you fill the form, and when posted, server GETs your variable KEY for use for whatever page author saw fit. It is a whole other story, whether you will see this variable on the form when it is reloaded after posting
What you see in the browser address bar is an HTTP URL which is just indicative of the HTTP Request being made.To see the complete HTTP Request - use Chrome - Developer tools. (HTTP Request /Response / Body / Cookie)
Your HTML page is formed by the Server you send the HTTP Request to. This HTML page is send back to the Browser in HTTP Response Body. Your browser which has layout (HTML) Engine running "just parses/renders the HTML in the HTTP Response".
The engine would - Parse to check for any HTML inconsistencies , to build DOM tree, to load scripts/images/css
Its purely you and only you who would decide as how to use the data. This data can either be used by JavaScript or Server Side code like JSP.
Other users have already suggested to you the way this can be achieved like running some script.
You need to print the value from the GET array into the value attribute of the input element. (ie. if you are using php use <input name="key" value="<?php echo $_GET["key"]; ?>" />)