Thanks to this beautiful and efficient tutorial makers!!!!!!!!!
Thanks for your huge contribution to the programmers struggling with code and new technology......
well,this code will not work for any other file than .txt.....but u can always upload the file into a folder and then copy the url to the database.....that will surely ensure all types of file upload !
For some reason in Linux is raising this exception:
java.lang.IndexOutOfBoundsException
this only happends with binary files on Linux.
To fix, add before this line:
int endPos = ((file.substring(0, boundaryLocation))
.getBytes()).length;
This lines:
if(endPos > formDataLength){
endPos = boundaryLocation;
}
Warning not fully tested!
Hi,
I have followed the code. I am using netbeans as my JSP editor and is using glassfish server. I wanted to know the location of the folder which stores the files when a user uploads them through this JSP page.
Thanks.
FinditUsefulDhamodharan Ravishankar September 23, 2011 at 9:25 AM
heh, i am Tarun i am following code that u have publish in site ..as that i am getting exception that"string out of range -1" i am resolved this..
please can u suggest me idea to get out of this
good job you did here pall...i was searching for this for 2 hours, i thought i have to read the file directly from client machine..but i was wrong...one question though: does this file remain on the server? or is just a temporary one?
Hi! I´m trying to upload files with ñ and acutes but I could not do. I tested with <%@ page language="java" contentType="text/html; charset=ISO-8859-15" pageEncoding="ISO-8859-15"%> I'm trying with this method <% Characters convertion
public String convert(String in) {
return in.replaceAll("&","&")
.replaceAll("ñ","ñ")
.replaceAll("Ñ","ñ")
.replaceAll("ó","ó");
} %>
but nothing... :( I guess that is the configuration of Apache server
IS it always that for upload in the jsp the form tag required and can it be done without using the form tag ..? if so den how to set the ENCTYPE="multipart/form-data".
This Jsp works fine. But in the html form if I have another input type eq text,
how will I capture the value of that text box and append it to the name of the file when I upload the file.
nice workpradip garala February 2, 2012 at 12:38 PM
code is fine it works also but where would be the file stored...i need to store the file in a folder and as well in the database plz tell how can we do that
I am not able to retrieve a text box value from "index_single_upload.jsp" to "single_upload_page.jsp" using request.getParameter("txt"). Its returning null. Can any body help on this.
This code works fine.I have a problem like a single file can be uploaded any number of time.What should i do to place a check to avoid uploading the same file.Thanks in advance.
Hi,
Thanks for this tutorial but I'm wondering, after the upload of the file, where it will be saved???
I want to save it in a folder on a remote server
thanks and good luck
Kim
When the file is binary and you convert the byte array into a String, because of decoding problems, you may get a string with a length possible larger than that of the byte array. Then, the endPos may turn out to be much larger than it should.
What I would do is:
-Decode using "UTF-8" That alone will not solve all problems, but header will be OK
-Since decoding problems can occur in the file contents but are unlikely beyond it, when calculating endPos, look for the distance from the end, rather than from the beginning, that is:
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
int fin = file.getBytes().length;
int distfinal = fin - endPos;
endPos = dataBytes.length - distfinal;
Thanxraktim April 2, 2011 at 11:14 PM
Thanks to this beautiful and efficient tutorial makers!!!!!!!!! Thanks for your huge contribution to the programmers struggling with code and new technology...... well,this code will not work for any other file than .txt.....but u can always upload the file into a folder and then copy the url to the database.....that will surely ensure all types of file upload !
Fix for Linux ServerGisler April 15, 2011 at 3:34 AM
For some reason in Linux is raising this exception: java.lang.IndexOutOfBoundsException this only happends with binary files on Linux. To fix, add before this line: int endPos = ((file.substring(0, boundaryLocation)) .getBytes()).length; This lines: if(endPos > formDataLength){ endPos = boundaryLocation; } Warning not fully tested!
Upload File at specified locationKalpesh April 20, 2011 at 6:16 PM
I want to store a file at specified location Folder what I do for tht....Please.....ans....
file uplodingrasanga June 2, 2011 at 4:42 PM
excellent work.
After uploading file, where it gets stored?Rohit June 15, 2011 at 2:59 PM
After uploading the file, if we want to see the uploaded file, where can we get the file?
File Upload queryUtsav Kesharwani June 14, 2011 at 11:37 AM
Hi, I have followed the code. I am using netbeans as my JSP editor and is using glassfish server. I wanted to know the location of the folder which stores the files when a user uploads them through this JSP page. Thanks.
FinditUsefulDhamodharan Ravishankar September 23, 2011 at 9:25 AM
Find it useful
complain..shan September 26, 2011 at 1:35 PM
not working.. error in line FileOutputStream fileOut = new FileOutputStream(saveFile);
about single image uploadkirubakaran October 8, 2011 at 1:37 PM
it and fantastic code in jsp.......
String index out of range -1 Tarun February 17, 2013 at 8:47 AM
heh, i am Tarun i am following code that u have publish in site ..as that i am getting exception that"string out of range -1" i am resolved this.. please can u suggest me idea to get out of this
Doubtsanjay November 16, 2011 at 4:05 PM
Hai i had a doubt, uploading a file (.txt, .doc , .html) and images to servers ,both are same ?
Doesn't Work on WebspherePrithwiraj Bose November 24, 2011 at 11:43 PM
Hi, I've repeatedly tested the code in Websphere server. But it doesn't work on Websphere. Although it works perfectly in Tomcat.
javaAnkit Sharma December 1, 2011 at 7:36 PM
it is really helpfull
coolemime December 15, 2011 at 10:33 PM
good job you did here pall...i was searching for this for 2 hours, i thought i have to read the file directly from client machine..but i was wrong...one question though: does this file remain on the server? or is just a temporary one?
Knowing file location after execution ?Fah January 4, 2012 at 8:49 AM
when i execute my project i don't know the file location after sending
Special CharactersCharly January 5, 2012 at 5:00 AM
Hi! I´m trying to upload files with ñ and acutes but I could not do. I tested with <%@ page language="java" contentType="text/html; charset=ISO-8859-15" pageEncoding="ISO-8859-15"%> I'm trying with this method <% Characters convertion public String convert(String in) { return in.replaceAll("&","&") .replaceAll("ñ","ñ") .replaceAll("Ñ","ñ") .replaceAll("ó","ó"); } %> but nothing... :( I guess that is the configuration of Apache server
thanks for the superb postsharath January 6, 2012 at 2:27 PM
It was very much helpful to me and also its very easy concept to upload the files. thanks for the superb post.....
can understandvictor January 12, 2012 at 3:16 PM
were is the location of the file uploaded
change location uploaddedi satriya January 15, 2012 at 7:59 AM
how to change the location of image when upload to specified folder
JSPRaguraman January 16, 2013 at 4:52 PM
how to find the uploaded file from the above source code.
query on uploadkartik January 13, 2013 at 1:25 PM
IS it always that for upload in the jsp the form tag required and can it be done without using the form tag ..? if so den how to set the ENCTYPE="multipart/form-data".
How to get value from another test boxMathew January 18, 2013 at 11:30 PM
This Jsp works fine. But in the html form if I have another input type eq text, how will I capture the value of that text box and append it to the name of the file when I upload the file.
nice workpradip garala February 2, 2012 at 12:38 PM
nice work.
UPLOADED CORRUPT FILESsantosh February 27, 2012 at 2:17 AM
Files do get uploaded but they are corrupt..please upload the proper code!!!
aise hiashish March 2, 2012 at 3:26 PM
thanks...
Single upload code doubtAviet March 13, 2012 at 12:22 AM
where does the file get uploaded?im askin the location?
Where would it store fileRatika March 23, 2012 at 9:35 AM
code is fine it works also but where would be the file stored...i need to store the file in a folder and as well in the database plz tell how can we do that
querypooja sethiya March 27, 2012 at 9:04 AM
wher did the file is being saved after uploading???
single file upload in jspchanaka March 28, 2012 at 5:07 PM
how can i change the saving path of new uploaded file?
jsp programrajalakshmi March 30, 2012 at 5:06 PM
i was try this program but can't save this file error
Not able to get other data from the formSurender March 30, 2012 at 6:33 PM
I am not able to retrieve a text box value from "index_single_upload.jsp" to "single_upload_page.jsp" using request.getParameter("txt"). Its returning null. Can any body help on this.
Where the file will uploadManu April 6, 2012 at 5:03 PM
Where can i find the uploaded file.
Good Mini-TutorialJulian May 3, 2012 at 9:35 AM
This was helpulf for me... Thanks
Uploading file checkRajasri July 1, 2012 at 6:36 PM
This code works fine.I have a problem like a single file can be uploaded any number of time.What should i do to place a check to avoid uploading the same file.Thanks in advance.
Uploading file rajasri July 1, 2012 at 6:40 PM
This code works fine.My problem is ,how to place a check on the file being uploaded to avoid multiple uploading of same file.Thanks in advance
The place of saving files??Kim July 25, 2012 at 1:24 PM
Hi, Thanks for this tutorial but I'm wondering, after the upload of the file, where it will be saved??? I want to save it in a folder on a remote server thanks and good luck Kim
how to get it backanisha August 27, 2012 at 3:00 PM
hi, how to retrieve the uploaded documents?
It wasnt usefuly at allMubasshir October 19, 2012 at 12:06 PM
Dint work for me
Queryami November 7, 2012 at 1:25 PM
can u please explain how to rename this file before saving on the server ??
Possible problems becvause of binary filesJ.L.Crespo November 30, 2012 at 5:21 PM
When the file is binary and you convert the byte array into a String, because of decoding problems, you may get a string with a length possible larger than that of the byte array. Then, the endPos may turn out to be much larger than it should. What I would do is: -Decode using "UTF-8" That alone will not solve all problems, but header will be OK -Since decoding problems can occur in the file contents but are unlikely beyond it, when calculating endPos, look for the distance from the end, rather than from the beginning, that is: int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length; int fin = file.getBytes().length; int distfinal = fin - endPos; endPos = dataBytes.length - distfinal;
Where to find uploaded file Nimesh April 6, 2013 at 10:32 AM
After file is successfully uploaded ,how to find loaction of file ??
why if the not select or null the sintak errorsatriya dedi January 18, 2012 at 11:21 AM
why if the not select or null the sintak error
Post your Comment