Forums Register Login

http status error 404

+Pie Number of slices to send: Send
Hi friends iam trying to upload 3 files in the desktop using FileUpload concept but i get the following error in the browser

i am using netbeans and the following message is the error message displayed





HTTP Status 404 - C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)



--------------------------------------------------------------------------------



type Status report



message C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)



description The requested resource (C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)) is not available.





--------------------------------------------------------------------------------



Apache Tomcat/5.5.9








The following two jsp codes are codes that i used



UploadFiles.jsp







<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">



<HTML>

<HEAD>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>

<TITLE>File Upload Page</TITLE>

</HEAD>

<BODY>Upload Files

<FORM name="filesForm" action="pf.jsp"

method="post" enctype="multipart/form-data">

File 1:<input type="file" name="file1"/><br/>

File 2:<input type="file" name="file2"/><br/>

File 3:<input type="file" name="file3"/><br/>

<input type="submit" name="Submit" value="Upload Files"/>

</FORM>

</BODY>

</HTML>







pf.jsp







<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">



<%@ page contentType="text/html;charset=windows-1252"%>

<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>

<%@ page import="org.apache.commons.fileupload.FileItem"%>

<%@ page import="java.util.List"%>

<%@ page import="java.util.Iterator"%>

<%@ page import="java.io.File"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Process File Upload</title>

</head>

<%

System.out.println("Content Type ="+request.getContentType());



DiskFileUpload fu = new DiskFileUpload();

// If file size exceeds, a FileUploadException will be thrown

fu.setSizeMax(1000000);



List fileItems = fu.parseRequest(request);

Iterator itr = fileItems.iterator();



while(itr.hasNext()) {

FileItem fi = (FileItem)itr.next();



//Check if not form field so as to only handle the file inputs

//else condition handles the submit button input

if(!fi.isFormField()) {

System.out.println("\nNAME: "+fi.getName());

System.out.println("SIZE: "+fi.getSize());

//System.out.println(fi.getOutputStream().toString());

File fNew= new File(application.getRealPath("/"), fi.getName());



System.out.println(fNew.getAbsolutePath());

fi.write(fNew);

} else {

System.out.println("Field ="+fi.getFieldName());

}

}

%>

<body>

Upload Successful!!

</body>

</html>



Kindly do help me in this regard......... Thank you in advance
+Pie Number of slices to send: Send
Hi,
As you did not use code tags so I did not look at your code but,

C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)



the above line suggests that there is a problem with the path of the file name and maybe not with the code.


Hope this helps
+Pie Number of slices to send: Send
Thank You for your reply Mr.Amit Ghorpade. I found out my exact problem, I did not include a line in that code and the problem that i faced was because of my browser.
+Pie Number of slices to send: Send
You are welcome,
Its always a pleasure to help
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1701 times.
Similar Threads
getting error while uploading file
Upload files from client
problem with commons FileUpload
Problem with File Upload
File Upload Error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:00:13.