File Upload, only work in server directory, PLS HELP!!

hi all,
my sevlet program work only if the source file is in the server where tomcat is installed. Can I upload the file in pc's local harddisc?
The following is my code:
import sun.net.ftp.*;
import sun.net.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class xupload extends HttpServlet
     FtpClient ftpClient;
     public void closeConnect()
          try{ ftpClient.closeServer();
          catch (IOException ex) {System.out.println(ex);}
     public void doGet(HttpServletRequest req, HttpServletResponse res)
          String ftpip = req.getParameter("ftp");
          String ftpuser = req.getParameter("user");
          String ftppwd = req.getParameter("password");
          String source = req.getParameter("source");
          String target = req.getParameter("target");
          try{
               PrintWriter out = res.getWriter();
                    FtpClient client = new FtpClient();
                    client.openServer(ftpip);
                    client.login(ftpuser, ftppwd);
                    client.binary();
                    out.println(ftppwd);
                    try {
                              TelnetOutputStream os=client.put(target);
                              java.io.File file_in=new java.io.File(source);
                              out.println(file_in);
                              FileInputStream is=new FileInputStream(file_in);
                              byte[] bytes=new byte[1024];
                              int c;
                              while ((c=is.read(bytes))!=-1){ os.write(bytes,0,c); }
                                        is.close();
                                        os.close();
                    catch (IOException ex) {System.out.println(ex);}
                    client.closeServer();
          catch (Exception e) { System.out.println(e.getMessage()); }
     public void doPost(HttpServletRequest req, HttpServletResponse res)
}

java.io.File file_in=new java.io.File(source);This is just picking up a filename sent from the browser and loading it from the server's filesystem.
You actually need to have the client send the file to the server. Libraries such as Jakarta Commons FileUpload make this easy. See:
http://www.onjava.com/pub/a/onjava/2003/06/25/commons.html?page=last&x-order=date
http://jakarta.apache.org/commons/fileupload/using.html

Similar Messages

  • Hi, I have installed some app to my I pad 1, It worked few days, but from tomorrow I can open any apps like calculator, Facebook ect. when touch it only vibrate does not come. pls help me

    Hi, I have installed some app to my I pad 1, It worked few days, but from lastday I can open any apps like calculator, Facebook ect. when touch it only vibrate does not come. pls help me

    It is ok now, I installed new app, then is ok

  • How can I restore my iPad Air to factory settings as I don't have internet on my laptop. After I erased everything from settings. It shows to restore n update through Apple server. Pls help me how to restore it to factory settings.

    How can I restore my iPad Air to factory settings as I don't have internet on my laptop. After I erased everything from settings. It shows to restore n update through Apple server. Pls help!

    Without internet connection there is no way for you restore the iPad.

  • Audio sound of loudspeaker and headphone of hp laptop is not working.... pls help me

    audio sound of loudspeaker and headphone of hp laptop is not working.... pls help me

    Hi @manishs400 
    I understand that you are having trouble with the sound on your speakers and headphones.I am happy to help with this.
    Please verify the operating system in use on your notebook. It is possible that it make be a driver related issue. Please seethe following for the HP customized drivers for this notebook.
    HP Pavilion dv4-3145tx Entertainment Notebook PC - Software & Drivers
    Also you should check out these pages, as it is quite possible you can find a resolution.
    No Sound from the Speakers (Windows 8)
    Resolving headphones and headset problems (Windows 8)
    From Microsoft's support website:
    Poor sound quality after upgrading to windows 8.1
    Automatically diagnose and fix Windows audio playback problems
    Let me know if any of that works for you.
    Malygris1
    I work on behalf of HP
    Please click Accept as Solution if you feel my post solved your issue, it will help others find the solution.
    Click Kudos Thumbs Up on the right to say “Thanks” for helping!

  • File Upload Not Work

    I have installed the File Upload sample in a Windows 2000 machine with 6i Form Server. When I start the web browser in the machine with the 6i Form Server, I can upload the file without problem. But when I start the web browser in another PC and accessing the 6i Form Server, the file seems uploaded but with 0 byte!!! Besides, the web browser in the PC hangs up.
    Please advise what is the most likely cause of the problem, thanks.
    SK

    I have several applications using the "multiple upload" behavior with clients on IE7 and flash player 9. Out 8 I only had same problem with one., even though they were created off the same base structure. The solution I found was as simple as it is mysterious.
    "Is the file you have this behavior located within the same directory as the "includes" folder or within another directory? "
    Let's say the directory of the includes folder is:
    root/public_html/includes
    and your page with the behavior is:
    root/public_html/folder/multiUpload.php
    For some reason and not on all sites if the file with the behavior is not in the same directory as the includes folder then the behavior you described occurs. The solution I came up with is to make a folder in the directory named "includes" and copy the "tng" into the folder on the same level as the file with the behavior.
    root/public_html/folder/includes
    root/public_html/folder/multiUpload.php
    Hope this works for you, it took me the better part of a week to figure this out, not sure why it works, I suspect a setting within ADDT was corrupted. Like I said before most of my clients don't have this problem even though they all use the same files (as in copies).
    Hope this helps
    M

  • File upload not working in mozilla

    I am using a input tag to upload a file.
    <input type="file" name="certFile" size="20" value="<%=certFile%>">
    This creates a file chooser with a text field and browse button.
    The upload works for IE but not for mozilla firefox ( These are the only two browsers I've tested this with ). The mozilla browser does not return the full file path, just the single name and extention of the file, so I'm getting a file not found error. But in I.E., the full path is returned and the file can be uploaded sucessfully.
    I've seen a few posts of similar problems, but none of them seem to have been resolved.
    Does anyone have any idea why mozilla is handling these file choosers differently and/or what I can do to possibly fix this problem?

    Huh?
    Your problem makes no sense. The filename is included with the upload so that the server knows what the file was originally called. Are you running the JSP locally and reading the file directly off the hard drive??
    I note also that you aren't using a multipart form, which is required to upload a file.
    <form action="uploadFile.jsp" method="post" enctype="multipart/form-data">
      <input type="file" name="upload" value="<%= fileName %>" />
    </form>You'll need to use the Jakarta Commons FileUpload class to correctly process a form encoded with "multipart/form-data" or getParameter("xxx") will return null. You can also use the older com.oreilly.servlet.MultipartForm or whatever it's called. I'm pretty certain that the Jakarta Commons obsoletes all the COS classes.
    Brian

  • File upload not working

    Hi,
    I am trying to implement a file upload following the how-to.
    But when I am trying to use the file browse item, the process of uploading stops - only the www_flow.accept sreen shows....sometime reload helps.
    I've tried Firefox and IE....
    Working locally on the server has the same result...
    Any idea / suggestions?
    Thanks in advance!
    Alex

    Addendum:
    IE 6.0 has after reload the following error code:
    Expecting p_company or wwv_flow_company cookie to contain security group id of application owner.
    Error ERR-7621 Could not determine workspace for application (:) on application accept.
    OK
    Alex

  • File upload not working on Mac OSX

    I've tried several of the Flex file upload components, in all
    cases they don't work correctly when used on a Mac. I've tested
    both flash player 9 and the latest 10 release. The file uploads to
    the server, but the progress bar doesn't update and the upload
    complete event never fires. To the end user, it looks like the app
    isn't doing anything at all!
    Any advice on how to get this working? If you know of any
    file upload components that are already tested and working on the
    Mac version of flash - that would be a great help as well!
    Thanks!

    If you Google it you will find that this is a known issue, it surprised me since I spent days looking at my code.
    I found possible solutions here, but none worked for me it seems that it worked for many other people.
    http://www.abdulqabiz.com/blog/archives/2006/06/09/workaround-filereference-oncomplete-is- not-fired-on-mac-os/
    Hope Mac and Adobe will have lunch one day and figure it out.
    Ben

  • File Upload in WebSphere App Server (3.5.4)

    Hi
    I am trying to upload a file from the client to the server. I am using oReilley's MultipartRequest to do this. This works fine in my Test Environment in Visual Age. But does not work in Websphere App Server.
    I get a "Error during native read operation". This happens mostly for big files more than 2 MB and sometimes for small files as well.
    Is this is a server issue? ('cos i tried using from jspsmart File Uplaod class and the result was the same).
    Any help is greatly appreciated.
    Thank You

    http://redeyeinteractive.com/index.eye?cart=1027565021121425&membersku=[membersku]&action=specific&SKU=507921572586523
    if this link don't work go to http://redeyeinteractive.com
    go to there java\applets path u will see a file upload component
    u can down load trial version free it is very easy to use.
    Good luck.

  • 9i File Upload not working on remote machine

    Hi.
    The 9i File Upload demo utility is working fine when I invoke it locally on the same machine.
    Remotely, however, I just get a grey blank screen in the browser with the message "Applet initialized" in the status bar. The java console says that the two JAR files were downloaded successfully, and doesn't show any other error.
    When I imported the cert on the client, the expiry date had already passed (sometime in 2002). I have generated a new cert, resigned the JAR file and installed it in the correct directory. Again, the upload works fine locally, but not remotely.
    Has anyone any idea what could be wrong? I'd be very grateful for any assistance. For info, we're using 9iDS 9.0.2.1.
    Thanks,
    Peter

    Please ignore my previous message.
    I rebooted the client and it now seems to work fine.
    Thanks anyway,
    Peter

  • [Struts]File upload doesnt work with "Create" but works with "CreateInsert"

    Hello,
    thank you for reading this!
    Im facing serious issue with web application built with JSP, Struts & ADF BC in jdeveloper 10.1.3.1 and jdeveloper 10.1.3.2 (same code works perfectly in older jdev versions)
    File upload to DB only works if CreateInsert is selected in PageDefinition. (Have to change from default "Create" to "CreateInsert")
    If I set "Create" i get this problems:
    - if VO is empty the row cannot be created (no error is returned, i click ОК and row is not commited, its just discarded)
    - if VO is not empty instead to create new row current row is updated.
    This only happens with "multipart/form-data" forms. With plain form row is created without the problem.
    If I change to "CreateInsert" then I can add new rows with "multipart/form-data" but i would prefer "Create" because it avoid the blank row issue...
    Old 10.1.3 works with "Create" and "multipart/form-data".
    Im aware of this problem since the 10.1.3.1 release but I havent posted on the forum because I hoped Oracle is aware of this problem but since the problem remains I decided to react. I do not have the metalink account so only way to address the issue is in this forum.
    Please Help.
    Sanja

    I had some problem with 'Create' earlier with 10.1.2. Then I kept recreateing the pages and then it worked finally. How are you creating the page for 'create' event. Is it like, first displaying the rows from the table with create button, or are you right away creating the page from menu option.

  • Download all files from a specific application server directory to Local pc

    Hi Experts,
    I have a requirement of downloading all the files from an application server directory to a local pc.
    I know how to download a single file from an application server at a time provided the file name is known.
    But my requirement is to download all the files in that particulary directory, because I dont know how many files were created in that directory and what are their names.
    Please kindly provide the solution.
    Thanks,
    Kalikonda.

    Nelson,
    Here is the function module that I have used to get all the application server files.
    appl_dir_name is the path of the directory  i.e. '/outbound/PD1/Applnserverfiles/'
    it_appl_srv_fls is the internal table where all the files gets stored in.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
       EXPORTING
         dir_name                     = appl_dir_name
      FILE_MASK                    = ' '
    IMPORTING
      DIR_NAME                     =
      FILE_COUNTER                 =
      ERROR_COUNTER                =
       TABLES
         dir_list                     = it_appl_srv_fls
    EXCEPTIONS
      invalid_eps_subdir           = 1
      sapgparam_failed             = 2
      build_directory_failed       = 3
      no_authorization             = 4
      read_directory_failed        = 5
      too_many_read_errors         = 6
      empty_directory_list         = 7
      OTHERS                       = 8
      IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    hope this solves your problem.
    Thanks,
    kalikonda.

  • HT1222 hello..i accidently delete all my files in may ipodtouch...and ican restore it..i need to have a 10.6.3 version of itune,but i cant download files,coz i only have 32 bit..pls, help what o do. i love my ipodtouch realy..i just want to restore my itu

    hello..i accidenty delete All my files in my ipod touch,,and icant restore my itunes,coz i need a version of itunes 10.6.3,but i only have 32bit..i cant download because they need 64bit,,pls,,help me dont know what to do,,i need to restore my itunes music..sorry im not good in english,,try to understand

    I assume you don't have a backup on an external HD. You always should, because then you could easily fix your problem.
    Boot in Safe Mode. See What is Safe Boot, Safe Mode? (Mac OS X)
    http://docs.info.apple.com/article.html?artnum=107392 Takes a while to run, but it usually "fixes" problems.
    Safe Boot takes longer than normal startup
    http://support.apple.com/kb/TS1884?viewlocale=en_US
     Cheers, Tom

  • Multiple file upload not working in IE10 and IE11

    Hi,
    As per the UI5 documentation( https://sapui5.hana.ondemand.com/sdk/#test-resources/sap/ui/commons/demokit/FileUploader.html) , UI5 supports multiple file uploading for IE10 and IE11. I set the "multiple: true" flag in the fileuploader example page and the file browser dialog is not allowing to select multiple files. Does UI5 provide multi file upload support for IE10 and IE11 or am i missing anything ?
    regards
    Raja

    Huh?
    Your problem makes no sense. The filename is included with the upload so that the server knows what the file was originally called. Are you running the JSP locally and reading the file directly off the hard drive??
    I note also that you aren't using a multipart form, which is required to upload a file.
    <form action="uploadFile.jsp" method="post" enctype="multipart/form-data">
      <input type="file" name="upload" value="<%= fileName %>" />
    </form>You'll need to use the Jakarta Commons FileUpload class to correctly process a form encoded with "multipart/form-data" or getParameter("xxx") will return null. You can also use the older com.oreilly.servlet.MultipartForm or whatever it's called. I'm pretty certain that the Jakarta Commons obsoletes all the COS classes.
    Brian

  • File sharing only works for users with Admin rights

    Hi.
    I am trying to set up file sharing in Lion Server but am having problems getting all my users access to shared folders. So far, only users that are "allowed to administer this server" are seeing shared files, even though they seem to have "read/write" permissions.
    Can anybody tell me what I might be missing?
    Is being allowed to "administer" the server different than truly being an Admin?
    I want to allow users to read and write files, but not change any server settings.
    Any suggestions would be appreciated.
    Thanks!

    What permissions are you setting on the share?  My guess is you are only using user, group, and other (POSIX).  You need to add an ACL to the list and then set read/write or full control.

Maybe you are looking for

  • How does APEX check for null values in Text Fields on the forms?

    Hello all, How does APEX check for null values in Text Fields on the forms? This might sound trivial but I have a problem with a PL/SQL Validation that I have written. I have one select list (P108_CLUSTER_ID) and one Text field (P108_PRIVATE_IP). I m

  • How to capture the event on changing focus from a JTextField?

    Hi All, I have got a problem... I want to do something (say some sort of validations/calculations) when I change the focus by pressing tab from a JTextField. But I am not able to do that. I tried with DocumentListener (jtf01.getDocument().addDocument

  • Audigy SE probl

    Hi all. Just installed an Audigy SE board and I've got some problems I need some help with. I'm running Win XP Pro SP2 Installed the board on a ECS nForce 570 motherboard. I disabled the onboard audio for the motherboard. And I have a 4 speaker set u

  • How to change the  attribute of screen field to drop down list dynamically

    Hi All,   Col X                   Col Y   A                        input field   B                       drop down list This is a tabular disply where the Screen field attribute for Col y  is NO DROP DOWN BOX. My requirement is to change the attribut

  • I can't set my classpath to compile serlets any help?

    I don't understand I'm doing it the way my book says to do it but I can't for the life of me set a freaking class path for my tomcat server so I can compile my serlets here's how it says to do it C:\Documents and Settings\Compaq_Owner\Desktop>javac -