Enctype="multipart/form-data" is notworking in linux environment? - linux

I have a web application and now we want to move that from windows to linux environment.Here issue is,If i use enctype="multipart/form-data" in form tag then post request fails.For testing purpose i have removed enctype="multipart/form-data" from form tag and run in linux environment.Now post request success,But as per my knowledge for uploading files we should use enctype="multipart/form-data" in form tag.How to solve this issue?Please help me,For all help thanks in advance.
<form action="#routes.HoForms.uploadHoFormsByHeadOffice()" enctype="multipart/form-data" method="POST" id="shiftSummaryForm">//post request fails in linux
<form action="#routes.HoForms.uploadHoFormsByHeadOffice()" method="POST" id="shiftSummaryForm">//post request success in linux

I find the solution for my problem above.What the problem is in my tomcat folder there is no folder created at the time of installation or may be i was deleted that folder unfortunately.Now i have temp folder in my tomcat folder and everything works fine.Thank you all for your valuable suggestions.

Related

Express combining two directories and changing the path

So I'm making an app with nodejs, express, and angularjs. I was following a couple of tutorials and decided to integrate into my project.
I have a index.html and there there is a button to create a multi-step form using Angularjs and UI-route. Form link
Then I found a youtube playlist for MEAN Stack, server works fine. As everyone I routed /public also.
app.use(express.static(__dirname + '/public'));
The problem starts here,
Button in the index.html it supposly goes to /app/views/forms/main-form.html to create the ui-view.
<div class="btn">
<form action="/app/views/forms/main-form.html">
<input type="submit" value="Get Started" />
</form>
</div>
Before I integrated express into my project, the path was working fine. Somehow, I think something to do with Express, when I click I get the following 404 error.
Refused to apply style from 'http://localhost:8080/app/views/forms/assets/css/form.css'
because its MIME type ('text/html') is not a supported stylesheet MIME type, and
strict MIME checking is enabled.
My problem is not about being a MIME type. The original path to CSS is /assets/css/form.css, but somehow it takes the form-main.html path at the beginning which is /app/views/forms also.
It is the same with formController as well. The controller normally is in the path of /app/controllers/formCtrl.js but the error goes like /app/views/forms/app/controllers/formCtrl.js
I would like to know how it takes two directories and combines them and why?
Edit
After using the CDN of Angularjs instead of local lib, it can get the link directly. But combining two directories is still continue to happening.

Netlify honeypot attribute missing on deployment

I have a django website that I'm using the django_distill app to generate a static site which I'm deplying to netlify. I've decided to add a bot protection field to a form (https://docs.netlify.com/forms/spam-filters/#honeypot-field ). When I run the site locally I see
<form data-netlify="true" name="consultdocs" netlify-honeypot="BOTFIELD" action="/contact/" id="form" method="post" novalidate="novalidate"> <input type="hidden" name="csrfmiddlewaretoken" value="rdKh4K2zu9T96aEUO9exSv3QCAm5w">
<input id="id_BOTFIELD" name="BOTFIELD" type="hidden">
....
When I deploy to netlify:
<form name="consultdocs" action="/contact/" id="form" method="post" novalidate="novalidate"><input type="hidden" name="form-name" value="consultdocs"> <input type="hidden" name="csrfmiddlewaretoken" value="GNnbYgQu6vLduSpWEswAVXfEx">
<input id="id_BOTFIELD" name="BOTFIELD" type="hidden">
....
I no longer see the :
netlify-honeypot="BOTFIELD"
attribute. Does netlify remove this?
In short: Yes, netlify removes this field.
I thought initially it's because of the missing data-prefix but netflify removes it independently if it's used with data-netlify="true" data-netlify-honeypot="BOTFIELD OR just netlify="true" netlify-honeypot="BOTFIELD.
I did a quick isolation test to ensure django is not doing some magic. So I simply used two static html files and pushed them to netlify:
https://gallant-edison-bf9c5f.netlify.com/index.html (w/o data attribute)
https://gallant-edison-bf9c5f.netlify.com/index2.html (w/ data attribute)
In both cases it disappears. You can check the respective source code for both files here:
https://github.com/christoph-kluge/netlify-example
I assume that netlify is parsing your HTML code during deployment and is adjusting it. Additionally netflify already checks if a specific post is a potential bot and drops those requests for you. So they need to do something with those fields.
Hope this answers your question.

Why is my download link requiring control click to download?

I am running a pretty basic node.js server to host a site, and all of a sudden this week one of my download links started to just redirect to the index.html page instead of downloading the pdf it points to if you just click on the file. a control+click will download the file, but that is not normal behavior from what I understand with chrome.
The button is generated as so:
<button type="button" name="button">
<a href="../images/a-manill-resume.pdf" download>Downloadable Resume</a>
</button>
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Try setting the download attribute
<button type="button" name="button"><a download="../images/a-manill-resume.pdf">Downloadable Resume</a></button>

Linux Server deployed JSP - Http 404 the requested resouce is not available

I am working on a web based project in eclipse on a system with jre 1.8 and Tomcat 8.
My application works fine on my system.
Now I have to deploy my application on a linux server machine.. As I am a novice I am facing some difficulties.
My server machine has Tomcat 7 installed.
For deployment , i was copying the sources from wtpwebapps from my system to /var/lib/tomcat7/webapps on my server machine.
But now only html webpages are showing up and all the jsp files are giving the HTTP: 404 The requested resource is not available.
My Folder Structure is MyProject/WebContent/(DisplayResults.jsp & Homepage.html) & servlet is located at MyProject/src/Utility/Servlet.java
Homepage.html
<form method="get" action="/MyProject/Servlet">
<input type='text' name='q' value='Type your text'><br>
<br> <input type="submit" value="Search">
</form>
Servlet.java
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String query = request.getParameter("q");
System.out.println("query is " + query);
request.setAttribute("itemList", list);
request.setAttribute("q", query);
RequestDispatcher view = request
.getRequestDispatcher("/DisplayResults.jsp");
view.forward(request, response);
}
DisplayResults.jsp
<%#page import="Utility.*"%>
<html>
<body bgcolor="#fdf5e6">
<table>
<td><c:forEach var="d" items="${itemList}">
<b><a href='<c:out value="${d.itemLink}"/>'>${d.itemTitle}</a></b>
<br>
<small>${d.itemLink}</small>
<p>${d.itemDesc}</p>
</c:forEach></td>
</table>
</body>
</html>
On server machine, the html file opens up but for jsp file it gives resource not available error.
I have read across through several related posts, I could not find the exact scenario being answered.I guess the issue is related to the class files for the jsp not being found. As I am copying the wtpwebapps folder manually , i think something is getting missed.
Kindly please help.
Also I would like to know where can I check errors on the server machine.
Since you are using eclipse you can create War file and deploy the same to your server machine's tomcat/webapps folder. Restart your Tomcat server and let tomcat auto load your application.
yourProject(Right Click)->export->web->war
There select your project, Provide name of the war file to be generated.
Note: Your application context will be same as your War file name.
In this way you can avoid any mistakes happening due to direct file transfer.
Another thing I noticed is that you are using your action url as /MyProject/Servlet.
Try using this in your form action Servlet.
Your form tag will become
<form method="get" action="Servlet">

Receiving 404.0 error when downloading a file on IIS 7 and Visual Studio 2010

I have an application which allows the users to upload and download files. The upload code looks like this:
[View]
<input type="file" name="file" id="file" />
<p />
<input type="submit" value="Upload" style="font-size:1em" />
</form>
[Controller]
public ActionResult Index(string id, FormCollection formCollection, HttpPostedFileBase file, int? FileID)
string filePath = "c:\\sandbox\\" + id + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + extension;
file.SaveAs(filePath);
The upload works fine. However, when I try to download the file just uploaded to "The Sandbox", I receive a 404 error. Here is the download code:
[View]
#f.Name
[Controller]
return File(a.FilePath, a.ContentType, a.Name); //File path is c:\Sandbox\filename
The application works flawlessly on my dev box, but fails when ported to IIS 7.5 box. Any thoughts would be extremely appreciated.
Thank you.
Found the problem!
When testing on dev box, the controller/action is located directly off the root. However, when deploying to the IIS box, the web site is placed in a sub-folder (xxxxxxx_deploy). Since the link to the controller action does not include the IIS sub-folder, it works on local box.
Thank you Mike!

Resources