i am unable to upload image in my webpage using html and jsp .....plz. help me
Printable View
i am unable to upload image in my webpage using html and jsp .....plz. help me
i have used this jsp code:
Code java:InputStream in = request.getInputStream(); System.out.println(in.available()); FileOutputStream fos=new FileOutputStream("D:/a.jpg"); int size=1024*1024; byte b[]=new byte[size]; int y=0; while((y=in.read(b))!=-1) { System.out.println(b); if(y==100){fos.write(b); } else { for(int j=0;j<y;j++) fos.write(b[j]); }} response.sendRedirect("rf1.jsp?"); %>
What errors are thrown? Also, can you format your code so that it is easier to read(i.e. tab things over, comment things out, etc.)?
--- Update ---
And use the code tags when posting chunks of code. You can find them under "Advanced Mode" the "Add Code Tags" button is on the right side, just hover over the buttons until you find it.
--- Update ---
By quickly glancing at your code, it doesn't look like there are any methods, not even the main() method. I believe that in order for any code to execute, it needs to be in a method.