Uploading zip file to server

Hi,
I want to upload a zip file in some server location,till now i have below code,but not able to get any clue how to upload zip file to server when user press Begin button.
Can someone please help me?
>
JSP code:
<af:inputFile label="Upload:"
valueChangeListener="#{ifarm.fileUploaded}"/>
<af:commandButton text="Begin"/>
Bean code :
public void fileUploaded(ValueChangeEvent valueChangeEvent) {
UploadedFile file = (UploadedFile) valueChangeEvent.getNewValue();
if (file != null)
System.out.println("************** "+file.getFilename().toString());
>>

All you need to do is to get hold of the input stream of the upload file and copy it to an file on your server (which you can create).
    public static int copy(InputStream input, OutputStream output)
            throws IOException {
        byte[] buffer = new byte[1024 * 4];
        int count = 0;
        int n = 0;
        while (-1 != (n = input.read(buffer))) {
            output.write(buffer, 0, n);
            count += n;
        return count;
    public void fileUploaded(ValueChangeEvent valueChangeEvent) {
        UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
        if (file != null) {
            File ff;
            try {
                // create a temporary file on the host server
                ff = File.createTempFile("xx", "yy");
                FileOutputStream os = new FileOutputStream(ff);
                IOUtils.copy(file.getInputStream(), os);
            } catch (IOException e) {
                e.printStackTrace();
            System.out.println("************** " +
                               file.getFilename().toString());
    }Timo

Similar Messages

  • Upload failed your changes were saved but could not be uploaded because of an error. you may be able to upload this file using server web page. save a copy

    Hi All,
    upload failed your changes were saved but could not be uploaded because of an error. you may be able to upload this file using server web page. save a copy button.
    This is the issue which I am facing while working with SharePoint 2010. In a sharePoint 2010 document library I am having an excel file and I am trying to open it from Windows 7 and is office 2010.
    I cam e across few suggestion as mentined below but unable to find the location where to do
    Go to Resource Policies > Web >
    Rewriting > Custom Headers > (if 'Custom Headers' is not visible, click
    Customize on the right top to enable the view).
    Create a new policy with the Resource as <fully qualified domain name of the SharePoint server:*/*> (for example https://sharepoint.juniper.net:*/* ).
    Create the action as Allow Custom Headers.
    Apply the settings to the required roles.
    Please suggest.

    Hi rkarteek
    All things you have to do is as follows:
    1. Open regedit.exe
    2. Naviagate to following key:
    [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\14.0\Common\Internet]
    3. Click Edit Menu -> New -> DWORD with name of "FSSHTTPOff"
    (without quotes)
    4. Click on "FSSHTTPOff" and enter value of 1
    5.
    Close any Office Applications and browser sessions
    6. Try to reopen your document (no more read only or failure to upload)
    have a nice day!

  • Uploading a file to server using servlet (Without using Jakarta Commons)

    Hi,
    I was trying to upload a file to server using servlet, but i need to do that without the help of anyother API packages like Jakarta Commons Upload. If any class for retrieval is necessary, how can i write my own code to upload from client machine?.
    From
    Velu

    <p>Why put such a restriction on the solution? Whats wrong about using that library?
    The uploading bit is easy - you put a <input type="file"> component on the form, and set it to be method="post" and enctype="multipart/form-data"
    Reading the input stream at the other end - thats harder - which is why they wrote a library for it. </p>
    why i gave the restriction is that, i have a question that <code>'can't we implement the same upload'</code>
    I was with the view that the same can be implemented by our own code right?

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • Upload ZIP File

    Hi Experts,
    Is it possible to upload multiple files or can we upload a ZIP file in web dynpro abap????
    I got to know about an intersting UI element of AcfUpDownload UI element, but still am not getting clear on it.
    Also I have checked in this link Web Dynpro ABAP Tutorial: ACFUpDownload and ACFExecute as well as standard component WD_TEST_APPL_ACFUPDOWN. But now I have confused a lot
    Please give me some idea, as how can I go ahead for uploading ZIP files.
    BR,
    RAM.

    Thanks Kiran,
    I was waiting for your reply only
    Even I saw the same Flash Islands wiki, but thought that I can do the same thing using normal web UI element itslef.
    Also please clear me one thing Kiran, can I use the File Upload UI element for uploading the ZIP File???
    As my client already has ZIP file in hand, I don't wish to go ahead for CL_ABAP_ZIP again.
    BR,
    RAM.

  • How to Upload a File to Server(JSP - Tomcat)?

    Hi,
    I want to upload a file to Server(Where the Tomcat is Running) to a particular directory.Let it be \tomcat\webapps\exapmles\Viki\.But note i dont have rights to map the drive from CLient side.I want to upload the file from client side to the unknwn server to a particular directory
    Please Help me
    Thanks in advance

    http://jakarta.apache.org/commons/fileupload/

  • Socket blocking on read operation while uploading zip file to the server

    I am trying to upload a zip file to the server
    Client thread creates the zip file ( of the modified files) and it even completes writing the data to the socket stream.
    Now if the server thread tries to read the same data from the stream, it blocks on read operation.
    While downloding the zip file from the server works fine.
    Thanks in advance

    You can use the URL object to upload it as multipart/form-data.
    http://forum.java.sun.com/thread.jspa?threadID=579720&messageID=3997264
    Or check out some of the file uploaders out there.
    http://www.google.nl/search?hl=nl&q=site%3Asun.com+upload+applet&btnG=Zoeken&meta=

  • Why does a link to zip file on server open a blank web page?

    Using CS6, I created this page:  J & B Computers - Projects I've uploaded 2 zip files and linked them from this page with this code:  <a href="Zip Files/CheckIPApp.zip" target="_blank">Download a zip file of the IP Checking utility</a> When this link is clicked, it opens up a blank tab instead of prompting for a download. I've tried it with and without the target=blank, I've also tried target=new... I've tried it in Chrome and Firefox. I've tried it on different computers. I've searched for an answer for hours...  what the heck is going on? I want the link to open up the save/download box and it just won't... TIA if you have a resolution!

    Since it's a file download, there's no reason to add the target="_blank", I'm guessing your file is 404 for some reason which would give you a blank window per the target.
    Make sure the case structure of the file and link are identical. Servers are case sensitive, a server sees CheckIPApp.zip and checkIPApp.zip as totally different files. Your local OS sees them as the same thing so during local testing it will work, when uploaded, it won't.
    Make sure you've loaded the file onto the server at the exact location specified by the link. It should be in a folder called "Zip Files" that resides on the same directory level as the page that the link is on.
    You may also want to normalize your file names. They should be all lower case alpha-numerics without any spaces (use hyphens or underscores instead) and without special characters ($%&*). You can use DW's Files window to change names and DW will fix the links automatically.

  • Error in uploading a file in server

    Hi,
    We are working in a application whose technologies are Flex 4.0 and .Net 2010.
    We are using .Net WCF Service for interacting with backend from the Flex front end.
    In our application, we have requirement to upload a file from the client into a server.
    We faced the following issue,
    Security violation Issue #2032.
    Solution: We have found that there is a sandbox restriction to access other domains, then we have placed the crossdomain.xml, which resolves the issue.
    But this solution works only in the IE.
    We are still getting the same error (Error #2032: Stream Error.) in other browsers - FireFox, Chrome and Safari.
    Please let us know if there are any suggestions or solutions for this issue.
    Regards,
    Guru

    Siva,
    You must apply modifiable binary type in wdDoInit of controller:
    ISimpleType stype =
      wdContext
        .node<YourNode>()
          .getNodeInfo()
            .getAttribute("FileResource")
              .getModifiableSimpleType();
    IWDModifiableBinaryType mtype = (IWDModifiableBinaryType)stype;
    /* Optional steps: affects only FileDownload control */
    /* mtype.setMimeType( WDWebResourceType.JPG_IMAGE);  */
    /* mtype.setFileName( "picture.jpg" );               */
    Sure, to make above work you must use binary type in context designer.
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • How do I create a slide where users can upload a file to server or email a file?

    Could anyone guide me in how I could go about creating a slide where users can either email a file or upload it to my server?
    Any help would be greatly appriciated...
    Steve

    Hello,
    Welcome to Adobe Forums.
    I am not sure how you can Upload a file, you might need a Javascript.
    You can create a slide and a button of that slide can call the default Email client (MS Outlook, Outlook Express....)
    1) On  you Slide insert a button (Insert -> Standard Object -> Button
    2) Double Click on that button and select "Open URL or file" for On Success (Under Properties Inspector)
    3) Write "mailto:[email protected]" in the URL box (For Example : [email protected])
    4) Publish the result, when you click on the button, it will call the default mail client.
    Screenshot :
    Note : This might not work if you have a Network Security which do not allow calling Mail Client through a Script (Clicking of Button calls the script)
    Thanks,
    Vikram

  • Uploading a file to server taking way too long

    When I upload a modified file to the server by selecting it in Local Files selecting Synchronize Dreamweaver reports as it goes through all kinds of directories on my server that do not contain this file. Why can't Dreamweaver just write the file to the directory it should know it's in?
    I'm running Dreamweaver CS4.
    Thanks.
    Steve

    I'm surprised nobody has answered this.  Just hit "Put" instead of synchronize.  Synchonize looks at every single file in your site and makes the server match what's on your computer.  So, synchronize forces DW to check every single file in your site folder.  If you just "put" the file, it only uploads the file/files you have selected.  Synchronize is a good feature to have, but you shouldn't use it every time you need to upload one file.

  • Uploading a file to server using ajax and struts

    My problem is i wrote a program to upload a file to the server using Ajax.
    Here iam used Struts and Ajax.
    The problem is when iam uploaded a file from my PC the file is uploading to the server in the upload folder located in the server my system.
    Iam using Tomcat server 5.0
    But when iam trying to access it through other system it is not doing so
    Giving an internal server error i,e 500.
    Iam putting the necessary documents for ur reference.
    Plz help me soon .
    My exact requirement is i have to upload a file to the upload folder located in the server.
    And i have to get the path of that file and display the file path exactly below the browse button from where iam uploaded a file.
    That should be done without page refresh and submit thats y iam used Ajax
    Any help would greatly appreciated
    Thanks and Regards
    Meerasaaheb.
    The action class is FilePathAction
    package actions;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    public class FilePathAction extends Action{
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    String contextPath1 = "";
    String uploadDirName="";
    String filepath="";
    System.out.println(contextPath1 );
    String inputfile = request.getParameter("filepath");
    uploadDirName = getServlet().getServletContext().getRealPath("/upload");
    File f=new File(inputfile);
    FileInputStream fis=null;
    FileOutputStream fo=null;
    File f1=new File(uploadDirName+"/"+f.getName());
    fis=new FileInputStream(f);
    fo=new FileOutputStream(f1);
    try
    byte buf[] = new byte[1024*8]; /* declare a 8kB buffer */
    int len = -1;
    while((len = fis.read(buf)) != -1)
    fo.write(buf, 0, len);
    catch(Exception e)
    e.printStackTrace();
    filepath=f1.getAbsolutePath();
    request.setAttribute("filepath", filepath);
    return mapping.findForward("filepath");
    the input jsp is
    filename.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <script type="text/javascript">
    alertflag = false;
    var xmlHttp;
    function startRequest()
    if(alertflag)
    alert("meera");
    xmlHttp=createXmlHttpRequest();
    var inputfile=document.getElementById("filepath").value;
    xmlHttp.open("POST","FilePathAction.do",true);
    xmlHttp.onreadystatechange=handleStateChange;
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send("filepath="+inputfile);
    function createXmlHttpRequest()
    //For IE
    if(window.ActiveXObject)
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    //otherthan IE
    else if(window.XMLHttpRequest)
    xmlHttp=new XMLHttpRequest();
    return xmlHttp;
    //Next is the function that sets up the communication with the server.
    //This function also registers the callback handler, which is handleStateChange. Next is the code for the handler.
    function handleStateChange()
    var message=" ";
    if(xmlHttp.readyState==4)
    if(alertflag)
    alert(xmlHttp.status);
    if(xmlHttp.status==200)
    if(alertflag)
    alert("here");
    document.getElementById("div1").style.visibility = "visible";
    var results=xmlHttp.responseText;
    document.getElementById('div1').innerHTML = results;
    else
    alert("Error loading page"+xmlHttp.status+":"+xmlHttp.statusText);
    </script></head><body><form name="thumbs" enctype="multipart/form-data" method="post" action="">
    <input type="file" name="filepath" id="filepath" onchange="startRequest();"/>
    </form>
    <div id="div1" style="visibility:hidden;">
    </div></body></html>
    The ajax response is catching in a dummy.jsp
    <%=(String)request.getAttribute("filepath")%>
    corresponding action mapping
    <action path="/FilePathAction" type="actions.FilePathAction">
    <forward name="filepath" path="/dummy.jsp"/>
    </action>
    So plz help me to upload a file to the server from any PC.
    Iam searched alot but didnt get any solution.

    Plz help me soon if it possible so
    Iam in great need.
    I have worked alot but not worked out.
    Any help greatly appreciated

  • Upload XML file from server to itab

    After failed to get a answer about download data from xml file in server to my itab, and searching and searching in hundred of post and threads i try my own solution for this issue.
    I read the file with:
    OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    In this case the result is a table filled with register type string like this:
    #<label>22222</label>
    I need a table with this kind of value (example):
    label   | 22222
    label2 | John
    label3 | Smith
    Therefore i have to parse the data of my table, i try with the FM:
    TEXT_CONVERT_XML_TO_SAP
    But dont works for me,
    I am too new in ABAP.
    The code for my report is very simple:
    REPORT ZPRUEBA_XML.
    DATA: BEGIN OF TABLA OCCURS 1,
    TEXTO(256) TYPE C,
    END OF TABLA.
    DATA: FICHERO LIKE RLGRAP-FILENAME.
    OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC NE 0.
      WRITE:/ 'ERROR'.
    ENDIF.
    FREE TABLA.
    DO.
      READ DATASET FICHERO INTO TABLA.
      IF SY-SUBRC NE 0.
        EXIT.
      ELSE.
        APPEND TABLA.
        WRITE: TABLA-TEXTO.
      ENDIF.
    ENDDO.
    CLOSE DATASET FICHERO.
    And my ".xml" in the server is very simple too.
    <label>222222</label>
    <name>John</name>
    <street>Smith, 23, NY</street>
    Anyone can help me?
    Thanks

    Hi,
    You could use a transformation to do that, or call FM 'TEXT_CONVERT_XML_TO_SAP'... you also have the class IF_IXML that should help you and a lot of threads on the subject, such as:
    convert XML data into ABAP internal table
    ABAP Class to convert XML to itab
    Upload XML to internal table and vice versa in SAP 4.6C
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e66701fc-0d01-0010-9c9a-f8a36c4e87ba
    Kr,
    Manu.

  • Problem uploading Dreamweaver file to Server

    Using CS3
    I cannot get my job to upload to the server correctly. The error code says: "Dreamweaver is currently interacting with a server.
    Since putting a file on save requires interaction with a server as well, DW cannot currently perform this task.
    Please try again when current server task is complete."
    And then it DOES save it to the remote site - but my links are not active and I am not able to access the job on internet.
    When I compare the remote site info it is synchronized with the local.
    My site setup has been tested and is good.
    I've been doing this job for 5 years. Not had this problem before.
    I have no other files/programs open and nothing is being saved that I know of. Sauve' 

    JTANNA wrote:
    VSauve\' wrote:
    Thanks for your reply.
    No I have not used any third-party upload files.
    I have contacted my host, but they haven't gotten back to me - Dreamhost - and I'm
    waiting and waiting . . . as my deadline gets later and later.
    In the meantime you could start using FileZilla - a free tool to upload your files.  Don't rely on Dreamhost because they could destroy your livelihood.  They couldn't care less about customers.  This is my experience with them.
    JTANNA wrote:
    1. Jan 9, 2012 7:19 PM (in response to MichaelCo)
    Re: Nav Bar collapsing in Dreamweaver
    MichaelCo wrote:
    Not sure what I am doing wrong.Any help would be appreciated.
    It is unlikely we would know either but have you uploaded/linked the relevant scripts and CSS files?  I believe PVII products rely heavily on scripts so this might be the problem
    I suggest repost your query to their forums as they should know what the problem could be.  We don't use any third party products here.
    Good luck.
    Oh the irony...
    VSauve\' wrote:
    Using CS3
    I cannot get my job to upload to the server correctly. The error code says: "Dreamweaver is currently interacting with a server.
    Since putting a file on save requires interaction with a server as well, DW cannot currently perform this task.
    Please try again when current server task is complete."
    And then it DOES save it to the remote site - but my links are not active and I am not able to access the job on internet.
    When I compare the remote site info it is synchronized with the local.
    My site setup has been tested and is good.
    I've been doing this job for 5 years. Not had this problem before.
    I have no other files/programs open and nothing is being saved that I know of. Sauve'
    From what you're describing that's happening you're syncing the whole site each time you are saving changes and there's a problem with the permission settings. I'm not saying that's the case but just from the description that's what it sounds like.

  • Uploading the file to server from the browser using JSP

    I have facing difficulty while uploading the file from the browser using user interface to the server or to the database. As previousy i was working in coldfusion, i find it very easy there with cffile command, but i am confused how to do that in JSP
    please reply soon, as i am stuck in my project because of that
    Sarosh

    Check out http://www.jspsmart.com , They have a nice free upload api that can be used w/ JSPs or Servlets. I hear O'Reilly has a nice one too. May as well use someone elses if they've done it already.

Maybe you are looking for

  • How to get the transport request number of ABAP query.

    I want to find out last Transport Request  number used of a transporting changes Abap query from development to quality system. Also is it possible to do some comparison on version existing in development and quality for abap query.

  • Spry menubar DW - I messed up?

    I created a Spry horizontal menubar in DW but I must have missed something in the instructions. I've followed several tutorials but can't get it straight. 1)  It looks funky online - comes out as a vertical list instead of a horizontal menubar. 2)  O

  • Install cs6 failure. Error code 213:19

    Hi, I can't get cs6 to install on my imac. Here's a detailed summary of what I've done: About this iMac : OSX 10.9, Processor: 3.6 ghz intel core i5. 8gb ram 1333 mhz DDR3,  GraphicsATI Radeon HD 5670 512 MB Migrated software from old powerbook by wa

  • Regarding Revenue Recognition

    Dear Friends, I configured Revenue Recognition to my service client.In general process after saving the billing document we can see  The bellow entries for accounting document. Customer a/c Dt Sales revenue a/c Cr All taxes are Cr But i want to know

  • Actual Cost? Actual Work? Scheduled Downtime EndDate?

    I am using SCSM 2012  and I have lot of Incidents. When I run this query: SELECT * FROM IncidentDimvw I receive a list of all my Incidents and his properties, but I have a lot of columns BLANK like: Actual Cost, Actual Work, Scheduled Downtime EndDat