Image upload in HTML not working - html

Here the code which i have used to upload the image to server.But it returns "The requested URL / was not found on this server." error.
<form name="uploadFile" action="http://http.brammies.com" method="post" enctype="multipart/form-data" onSubmit="return validate();">
<input type="hidden" name="choice" value="upload">
<table align="center">
<tr>
<td><span style="color:red;font-weight:bold">Upload files</span></td><td><input type="file" id="ufile" name="ufile" onKeyPress="return false;" style="BACKGROUND-color:Thistle">(* jpg,gif,png)</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Upload" style="BACKGROUND-color:Thistle"></td>
</tr>
</table>
</form>
Can any one tell me whats wrong with my code?

The URL http://http.brammies.com does not refer to a form handler. From the outside, it is impossible to tell what the action attribute value should be.
From the response given by the server when http://http.brammies.com is accessed directly, it seems that the attribute value should be http://http.brammies.com/cgi-bin/ followed by some filename of a CGI script.

Related

Add binding error messages to custom messages in input tag

I am playing with the Spring validating form input example - java spring mvc with Thymeleaf views. I have been able to pass messages into the view without issue. These display where the example wants them to...
e.g.
<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>
I am trying to find a way to put them into the html input validation attributes though so I have tried the following (full page below)
<td><input type="text" th:field="*{age}" **required="required" data-errormessage-value-missing="${#fields.errors('age')}" data-errormessage="${#fields.errors('age')}"**/></td>
This has done no good though and the validation message displayed is ${#fields.errors('age')} ! Is there a way to push the binding errors into the attribute or am I misunderstanding the way it works ?
Thanks for any help in advance.
Page html
<html>
<body>
<form action="#" th:action="#{/}" th:object="${personForm}" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" th:field="*{name}" required="required" data-errormessage-value-missing="Custom Message" /></td>
<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" th:field="*{age}" required="required" data-errormessage-value-missing="${#fields.errors('age')}" data-errormessage="${#fields.errors('age')}"/></td>
<td th:if="${#fields.hasErrors('age')}" th:errors="*{age}">Age Error</td>
</tr>
<tr>
<td><button type="submit">Submit</button></td>
</tr>
</table>
</form>
</body>
</html>
Thymeleaf only evaluates attributes that start with th:, so in order to do this, you have to use th:attr. You're tag should look like:
<input type="text" th:field="*{age}" required="required" th:attr="data-errormessage-value-missing=${#fields.errors('age')}, data-errormessage=${#fields.errors('age')}" />
You could also use this plugin to evaluate data tags, but I've haven't used it before so I can't comment on how well it works: https://github.com/mxab/thymeleaf-extras-data-attribute

How can I get browsers to prompt user to save submitted username/password?

I've reviewed this post and this post, but they work for me. Those posts are 4-5 years old, so perhaps the browser rules for this have changed or gotten more specific?
Here is the form for login. There is no ajax and no javascript of any kind. I've tried changing the the input name from usernameOrEmailAddress to username and that doesn't change anything.
<form method="post" name="loginForm" id="loginForm" action="login-check.php" autocomplete="on">
<table>
<tr>
<th>Username or Email Address</th>
<td><input autofocus type="text" name="usernameOrEmailAddress" value="" required></td>
</tr>
<tr>
<th>Password</th>
<td><input id="password" type="password" name="password" value="" required title="Password"></td>
</tr>
</table>
<div class='row'>
<input class="inputsubmit button" name="login" type="submit" value="Login" />
</div>
</form>
Neither Chrome nor Firefox prompt to save the password for next time. What am I doing wrong?
Most browsers will do this automatically as long it can detect a username and a password field. Here is a picture on my computer when I just copy and pasted your code.
If it doesn't work for you, clear your cache and cookies then attempt again. Also what browser(s) are you using?

At what point does the upload occur in an html form?

Okay, so I've been handed this code (surrounding code is standard head/body framework and script defining "ConvertPPT2HTML()"):
<h1>Powerpoint Upload</h1>
<form id="form2" enctype="multipart/form-data" action="test_ppt_uploader.php" method="POST">
<table border="0" >
<tr>
<td ><b>Select File:</b> </td>
<td>
<input type=hidden name="pptfilename" id="pptfilename" value="">
<input type=hidden name="tempfilename" id="tempfilename" value="">
<input type="file" name="uploadedfile" id=upload size=25 >
</td>
<td>
<input type="submit" name=sub value="Upload File" onclick=" return ConvertPPT2HTML();"></td>
</tr>
</table>
</div>
</form>
The requirements are to:
Stop it from uploading any files from the client to the server
Keep it doing the ConvertPPT2HTML work (basically using AJAX to open the actual ppt file at the supplied path, saving a temp copy and a copy as html and then zipping it up for later upload)
The actual file is available in the php script after submit is hit, so my initial take was to remove:
enctype="multipart/form-data" action="test_ppt_uploader.php" method="POST">
Which does the job. But I'm not sure if the file is still being uploaded and discarded, or if it's not being uploaded at all.
I do want to keep the file widget around for browsing the file system, I just want to ensure it merely gives you a path, not an uploaded file.
So the specific question is Does the code below still upload anything?
<h1>Powerpoint Converter</h1>
<form id="form2">
<table border="0" >
<tr>
<td ><b>Select File TWJC:</b> </td>
<td>
<input type="file" name="uploadedfile" id=upload size=25 >
</td>
<td>
<input type="submit" name=sub value="Upload File" onclick=" return ConvertPPT2HTML();">
</td>
</tr>
</table>
</div>
</form>
Yes, if ConvertPPT2HTML() returns true then your form will still upload the PPT to the server. The form's action attribute defaults to the current URL.
You can use the "Network" tab in Chrome or IE's developer tools to watch the form submission.

HTML generated by Dreamweaver

When i run the following code below it works in dreamweaver but when i go to view it in a web broswer nothin shows.
The code is
<table cellpadding="5" cellspacing="1">
<tr>
<td align="center">
<form action="search.php" method="get">
<table><tr><td>
<input type="text" name="query" id="query" size="40" value="<? print quote_replace($query);?>" action="include/js_suggest/suggest.php" columns="2" autocomplete="off" delay="1500">
</div>
<td>
<input type="submit" value="Search!">
</td></tr></table>
When i go to view the source code in chrome it only loads
<table cellpadding="5" cellspacing="1">
<tr>
<td align="center">
<form action="search.php" method="get">
<table><tr><td>
Check with your host to see if they've enabled the <? tag. It's not turned on by default. If it's not, it's probably causing Chrome a lot of grief.
Check out your syntax. What you've pasted isn't valid. It looks like your'e closing your form twice, or you have an extra set of quotes in the "get" area.
On a side note, I suggest removing display related HTML attributes in favor of CSS. It will help keep a clear distinction between function and look.

Why data not retrieved using request.getParameter() when using post method in html

In my jsp code I use the request.getParameter() to retrieve the data which is entered in html. The data was retrieved when using get method but it is not when im using post method
Why this happend
My html form is
<code>
<form name="inp" action="upload.jsp" method="post" onsubmit="return valid();" enctype="multipart/form-data">
<table align="center" cellspacing="2">
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td><font size="5" color="#E41B17">Select File</font> </td>
<td><input type="file" name="infile"></td>
</tr>
<tr><td><font size="5" color="#E41B17">Target File Name</font></td>
<td><input type="text" size="20" name="filename"></input></td>
</tr>
<tr></tr>
<tr><td colspan="2" align="center"><input type=submit value="Upload" ></td></tr>
</table>
<br></br>
<center>
<font color="#E41B17">HOME</font>
</center>
</form>
</code>
And my jsp scriptlet is
<% String f = request.getParameter("filename");
System.out.println(f); %>
Thanks in Advance
Now to the issues: you've set the form's content type to be multipart, which means that you have to explicitly parse the request body; the container will only parse if you leave the default form-encoded. This article seems to give an example of how to access multipart data on the server side.
Aside from that, you do realize that your form is commented-out, so should never be handled by your browser, right? If you're actually seeing something on the browser, it probably isn't coming from this location.