Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP 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 May 7th, 2005, 08:36 AM
Authorized User
 
Join Date: May 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to subhasis.chakraborty Send a message via Yahoo to subhasis.chakraborty
Default Its Urjent : It all about writing a file in the se

Hello I have come up of a problem that I like to upload a file from the client machine to the server . I have got hold of a byte[] and now the problem is that how can I change the byte array to a corresponding file .. Can any one help me out with a solution ...

          Thanks in advance for the solution
 
Old May 31st, 2005, 06:20 AM
Authorized User
 
Join Date: Apr 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try the JSP Smart Upload package, you have to download it,
then the following code is for uploading pictures:

Code:
<%@page contentType="text/html; charset=big5"%>
<%@page import="java.util.*,java.sql.*,java.net.*,java.io.*"%>
<%@page import="com.jspsmart.upload.*"%>
<%@page import="nesonline.*"%>
<html>
<head>
<title>file</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<link rel="stylesheet" type="text/css" href="all.css" />
</head>
<body>
<%
  String login = (String) session.getAttribute("login");
  if (login != null && login.equals("success")) {
%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload"/>
<%!FileUpload fileUpload = new FileUpload();%>
<%
  String sevID = (String) session.getAttribute("sevID");
  mySmartUpload.initialize(pageContext);
  mySmartUpload.setMaxFileSize(1024 * 1024);
  String path = (String) application.getRealPath("\\images\\empPhoto\\small") + "\\";
  mySmartUpload.upload();
  fileUpload.getQuery(sevID);
  for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
    com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);
    if (!myFile.isMissing()) {
      myFile.saveAs(path + fileUpload.getPhotoNo() + ".jpg");
      myFile.saveAs(path + fileUpload.getPhotoNo() + ".gif");
    }
  }
  response.setHeader("Refresh", "1;URL=pd.jsp");
%>
<%
  } else {
    out.println("<center><h1>±zÁÙ¥¼µn¤J¡I</h1></center>");
    response.setHeader("Refresh", "2;URL=index.jsp");
  }
%>
</body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
writing into a file in linux file system anboss XSLT 6 June 19th, 2008 01:56 PM
writing a shape to a file ironchef Java Basics 0 November 8th, 2006 06:35 PM
writing an object to a file ironchef Java GUI 0 November 8th, 2006 06:35 PM
writing into xml file jerryjohn XML 1 August 18th, 2006 02:40 AM
Its urjent : Writing a file in the server subhasis.chakraborty JSP Basics 0 May 7th, 2005 08:19 AM





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