Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2008, 04:23 AM
Registered User
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default FileUpload is working with IE, not with Mozila

UploadImage.jsp
<body>
<form name="UploadImage" method="post" action="UploadImageServlet" >
Building Image:
<INPUT type="file" Size="33" contentEditable="false" name=image value="Upload"><br
<INPUT name=Submit type=submit value=Submit />
</form></body>
UploadImageServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
public class UploadImageServlet extends HttpServlet {
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try{
   String image=request.getParameter("image");
   InputStream stream = new FileInputStream(image);
   OutputStream bos = new FileOutputStream("C:\\Temp\\image.jpg");
   int bytesRead = 0;
   byte[] buffer = new byte[8192];
   while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
   bos.write(buffer, 0, bytesRead);
    }
    bos.close();
    stream.close();
    }catch (Exception e){
     System.out.println("Exception Raised");
      e.printStackTrace();
      }
   } }
------------------------------------------------------------

Web.xml
<web-app>
<servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>UploadImageServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>/UploadImageServlet</url-pattern>
</servlet-mapping>
</web-app>
================================================== ========


When I run this application using IE then image is created in c:\Temp location.
But if you use Mozila ,the image is not stored in c:\Temp location.


WHY ?(for that is it require to change code)



venkatesham
 
Old April 20th, 2009, 07:11 AM
Authorized User
 
Join Date: Jun 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to erobb Send a message via Yahoo to erobb
Default

This is Java not JavaScript. You may want to post in the Java forum. They will probable want to know the code in your servlet.

Earl
http://www.duckin4printing.com/
 
Old April 21st, 2009, 04:35 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Yes, Javascript is a light scripting language for creating client side behaviors on the webpage not heavy programming like Java.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Fileupload in Ajax bobwith5 ASP.NET 2.0 Professional 3 October 18th, 2008 09:59 AM
FileUpload control aliirfan84 ASP.NET 2.0 Professional 1 June 2nd, 2007 03:37 PM
Output should appear in Mozila instead of IE anujrathi ASP.NET 1.0 and 1.1 Professional 2 August 30th, 2006 09:47 AM
FileUpload FIlter tony_j_hug ASP.NET 2.0 Basics 1 October 28th, 2005 06:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.