473,756 Members | 1,841 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 1920

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

Similar topics

4
2779
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 4.2. 3, not in safe mode. I think that the basic problem is the set-up for the temp folder, but I don't have access to the .ini settings. I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
9
2377
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 uploaded, it will be available at the "upload_tmp_dir" (usually /tmp) directory. Then you may move that file to another directory using move_uploaded_file(); file name will be available in the superglobal $_FILES. Refer:...
5
7837
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 files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at a time and providing status updates via a GUI interface. Finally, I close the socket, set it to...
1
2206
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 uploading a file to the server is 4Mo but I changed that maximum to about 10Mo in my web.config file : <httpRuntime executionTimeout="45" maxRequestLength="10000" useFullyQualifiedRedirectUrl="true" />
5
5476
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 replacing it with a button of my own background color and text. The file paths I'd like displayed in a textarea and then the files uploaded at once.
13
4320
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 that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
3
2642
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 override, so that I can catch the event when while user's uploading a file, then suddenly closes the browser. In that case, couple things happens: 1) ASPNET will start eating up the uploading file on memory instead of on disk (so picture a...
5
2727
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 more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently considering: Page 1: Meeting Information input with link to a document upload page (this page...
1
2080
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 on Win2003, IIS, ASP.Net 1.1. The page works fine if running from localhost. It only has problem when accessed from a domain name.
3
1915
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 work properly. That means the file is not uploaded to the specified location. It always executes the "else" condition in my coding. I think the problem is lieing in the specifed path which is the target path for file uploading. I could not find out...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5140
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.