473,507 Members | 3,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uploading file

46 New Member
hai.

i have one problem that is to upload file..it working perfectly in my computer but fail when deploy at server..the system is to browse the file,then system will zip it before upload it to the server..when a client browse file,the server will generate error that is file not found.here is my code:

Expand|Select|Wrap|Line Numbers
  1.  try {
  2.             //this is a code to read and zipfile
  3.             String dir = request.getParameter("dirs");
  4.             System.out.println(dir);
  5.             String tmp = dir.replace( '\\', '/' );
  6.             System.out.println(tmp);
  7.             String inFilename = tmp;
  8.            // String inFilename = dir;
  9.             String outFilename = "c:/sms.zip";
  10.           //String outFilename = "/webapps/ROOT/sms.zip";
  11.             FileInputStream in = new FileInputStream(
  12.                     inFilename);
  13.             ZipOutputStream out = new ZipOutputStream(
  14.                     new FileOutputStream(outFilename));
  15.  
  16.             // Add ZIP entry to output stream.
  17.             out.putNextEntry(new ZipEntry(inFilename));
  18.  
  19.             byte[] buf = new byte[1024];
  20.             int len;
  21.  
  22.             while ((len = in.read(buf)) > 0) {
  23.                 out.write(buf, 0, len);
  24.             }
  25.             //end of zipping file
  26.  
  27.             //start uploading
  28.             SimpleFTP ftp = new SimpleFTP();
  29.  
  30.             // Connect to an FTP server on port 21.
  31.             ftp.connect("xxxxx", 21, "xxx", "xxxx");
  32.  
  33.             // Set binary mode.
  34.             ftp.bin();
  35.  
  36.             // Change to a new working directory on the FTP server.
  37.             ftp.cwd("web");
  38.  
  39.             // Upload some files.
  40.             ftp.stor(new File("sms.zip"));
  41.  
  42.             ftp.disconnect();
  43.             //finish uploading
  44.             out.closeEntry();
  45.             out.close();
  46.             in.close();
  47.             response.sendRedirect("../BakMeClient/success.jsp");
  48.         } catch (IOException e) {
  49.             System.out.println(e);
  50.         }
String dir is the location of file.
Jan 12 '10 #1
0 1900

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2762
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP...
9
2365
by: R. Rajesh Jeba Anbiah | last post by:
Q: How should I handle file upload? A: File uploading requires HTML form of content type "multipart/form-data". The file content has to be POSTed/submitted via the form and once the file is...
5
7815
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
1
2190
by: Jonathan | last post by:
Hi everyone, I have a problem with the file uploading in Asp.Net and I have read a lot on forums on this but never found an answer. Here is the problem: I know Asp.Net maximum Length for...
5
5448
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
13
4281
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
3
2616
by: Jason Chu | last post by:
I've written a file uploading part of my application using the IHttpModule. So now, I don't have the memory problem of uploading something big. Problem: I can't find which function I have to...
5
2709
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
1
2066
by: wenqiang7 | last post by:
I am encountering a very strang problem with file uploading in my ASP.Net page. When we try to upload certain file, we'll get an error msg of "Cannot find server or DNS Error". We are running...
3
1900
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.