Upload and Download of files

I am working on a web site development work. I am working with STRUTS framework tht is made over the jsp tag library..Can any one help me about how to upload and download files from server and to the server.If possible using struts framework. Pls do give a pratical example..
regards jay

Like this:
        //upload
        String fileName = formFile.getFileName();
     Sting  destFile = "c:/upload/" + fileName;//path to save the upload file on server
     try {
             InputStream     in = formFile.getInputStream();
          OutputStream     out = new FileOutputStream( new File(destFile) );
          int n = 0;
          byte[] buff = new byte[8192];
          while( (n = in.read( buff, 0, 8192 )) != -1 ) {
               out.write( buff, 0, n );
          out.close();
          in.close();     
        }catch(Exception e){
        //download
        String serverFile = "c:/upload/a.txt";//file path on server to be downloaded
        File serverF = new File(serverFile);
        response.setContentType("text/html");
     response.setHeader("Content-Disposition","attachment;filename="+serverF.getFileName()+";");
     try {
         ServletOutputStream outStream = response.getOutputStream();
         FileInputStream stream = new FileInputStream(serverF);
         BufferedInputStream  bis = new BufferedInputStream(stream);
         BufferedOutputStream bos = new BufferedOutputStream(outStream);
         byte[] buff = new byte[2048];
         int bytesRead;
            try{
             while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                  bos.write(buff, 0, bytesRead);
         } catch (Exception e) {
            } finally {
        if (bis != null) bis.close();
        if (bos != null) bos.close();
        if (stream != null) stream.close();
     }catch (IOException e){
     }

Similar Messages

  • How to upload  and download a files into AL11 directory in ABAP

    Hi,
                   How to upload  and download a files into AL11 directory in ABAP
    thanks
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Mar 21, 2011 9:18 AM

    You should try one of these forums for an answer to your question:
    http://swforum.sun.com/jive/forum.jspa?forumID=116
    http://community.java.net/netbeans
    http://linux.java.net

  • Apex application file -upload and download a file.

    hi
    im having an issue with an application i created,its about uploading and downloading a file in application.the application is working and was able to upload and download a file but i have not idea there the file is stored in the application database,try to search for the file,its something dealing with the apex_application_file and i cant find it.
    Any idea where the file is stored?
    thnx
    nivesh

    Dear nivesh!
    If you upload a file into an APEX application the file is temporarily stored in the APEX_APPLICATION_FILES table. If you close your current application page the APEX_APPLICATION_FILES table will be cleared. You should create your own table to store files in a BLOB column. I've create an example for uploading images into an APEX application on apex.oracle.com. If you want to have a look at it please use the following credentials:
    Workspace: flo_demo
    Username: dev_null
    Password: password
    Application: 61811
    Yours sincerely
    Florian W.

  • How to upload and download any file from plsql through weblogic server

    hi all,
    how to upload and download any file from plsql through weblogic server? i am using oracle 10g express edition and jboss.
    Thanks and Regards,
    MSORA

    hi bala ,
    for a windown server u can use VNC (virtual network connection) which opens a session on u r desktop later u can drag and drop form there vice versa and for a linux box you can use Win SCP which helps to open a session with interface to u r desktop in both cases you can upload and down load files very easiy just as we drag and drop items in a simple pc .. we use the same technique...
    bye
    vamshi

  • Upload and download the file same name but different extension from the document library.

    HI,
         I am using the Client Object Model (Copy. Asmx ) To upload and download the file from the document library.
    I am having the mandatory File ID for the each Document.
    I tried to upload the the document (KIF53.txt) with File ID (KIF53) uploaded successfully.
    Again I tried to Upload the document(KIF53.docx) With File ID(KIF53) its uploaded the file but it not upload the File ID in the Column
    Please find the below screen shoot for the reference.

    thanks ashish
    tried 
    My requirement is to create the  folder and sub folder in SharePoint document library. If already exist leave it or create the new folder and the subfolder in the Document library using client side object model
    I able to check for the parent folder.
    But cant able to check the subfolder in the document library.
    How to check for  the sub folder in the document library?
    Here is the code for the folder IsFolder alredy Exist.
    private string IsFolderExist(string InputFolderName)
            string retStatus
    = false.ToString();
            try
                ClientContext context
    = newClientContext(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryLink"]));
    context.Credentials = CredentialCache.DefaultCredentials;
                List list
    = context.Web.Lists.GetByTitle(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryName"]));
                FieldCollection fields
    = list.Fields;
                CamlQuery camlQueryForItem
    = new CamlQuery();
    camlQueryForItem.ViewXml = string.Format(@"<View 
    Scope='RecursiveAll'>
    <Query>
                          <Where>
    <Eq>
    <FieldRef Name='FileDirRef'/>
    <Value Type='Text'>{0}</Value>
                            </Eq>
    </Where>
    </Query>
    </View>", @"/sites/test/hcl/"
    + InputFolderName);
    Microsoft.SharePoint.Client.ListItemCollection listItems
    = list.GetItems(camlQueryForItem);
    context.Load(listItems);
    context.ExecuteQuery();
                if (listItems.Count
    > 0)
    retStatus = true.ToString();
                else
    retStatus = false.ToString();
            catch (Exception ex)
    retStatus = "X02";
            return retStatus;
    thanks
    Sundhar 

  • How to upload and Download the file in a system through java programing

    I am trying to upload a file as well as want to download the uploaded file in my system....I don't have any server an all.
    I want to implement this in my system only .
    I got this code but i don't know ,where i have to make the change and what are the parameters i have to pass.
    can any one help me on this code ....please
    here some piece of code
    File Upload and Download Code Example
    package com.resource.util;
    public class FileUpload
    public void upload( String ftpServer, String user, String password,
    String fileName, File source ) throws MalformedURLException,
    IOException
    if (ftpServer != null && fileName != null && source != null)
    StringBuffer sb = new StringBuffer( "ftp://" );
    // check for authentication else assume its anonymous access.
    if (user != null && password != null)
    sb.append( user );
    sb.append( ':' );
    sb.append( password );
    sb.append( '@' );
    sb.append( ftpServer );
    sb.append( '/' );
    sb.append( fileName );
    * type ==> a=ASCII mode, i=image (binary) mode, d= file directory
    * listing
    sb.append( ";type=i" );
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    try
    URL url = new URL( sb.toString() );
    URLConnection urlc = url.openConnection();
    bos = new BufferedOutputStream( urlc.getOutputStream() );
    bis = new BufferedInputStream( new FileInputStream( source ) );
    int i;
    // read byte by byte until end of stream
    while ((i = bis.read()) != -1)
    bos.write( i );
    finally
    if (bis != null)
    try
    bis.close();
    catch (IOException ioe)
    ioe.printStackTrace();
    if (bos != null)
    try
    bos.close();
    catch (IOException ioe)
    ioe.printStackTrace();
    else
    System.out.println( "Input not available." );
    }

    At least that is what the code you posted suggests to me.It looks like that to me too.
    I believe that
    URLConnection urlc = url.openConnection(url);Will return you an FTP URLConnection implementation if you pass it a ftp:// url
    So for simple FTP ops, you don't need any external libs.
    Actually, looking at your code, this is already what you are doing, so I really don't get this:
    am not using FTP server..... i want to implement in my system only ....So How i will do.
    Can you give me any idea based on this code Can you explain a bit more what you need?
    patumaire

  • How to upload and download a file in server side program

    Give me a sample code for the file upload and download using Server side program.

    You should try one of these forums for an answer to your question:
    http://swforum.sun.com/jive/forum.jspa?forumID=116
    http://community.java.net/netbeans
    http://linux.java.net

  • To upload and download any file to the server

    Hi,
    I want to upload and download files into and from the server; as we do it in yahoo attachments. Give the location of the file, click upload, it must upload the file to the web server and click on the uploaded file, it should get downloaded. i want to do this in Application server.
    Can anyone help me on this please......
    Thanks in advance,,
    Bala

    hi bala ,
    for a windown server u can use VNC (virtual network connection) which opens a session on u r desktop later u can drag and drop form there vice versa and for a linux box you can use Win SCP which helps to open a session with interface to u r desktop in both cases you can upload and down load files very easiy just as we drag and drop items in a simple pc .. we use the same technique...
    bye
    vamshi

  • Can u please send me a sample code to upload and download a file using java

    Hi,
    Please can u send me a sample code to upload a file and to download the same file from a remote server using a java servlets. The file should be read byte by byte.
    Message was edited by:
    user461713

    Hi, Thank u.
    Sorry, I forgot to attach a code. Here it is.
    Actually i need to upload a file to a remote server and download it from a server to my machine. I'm trying it using servlets and using tomcat5.0 as a servlet container. Here i'm sening a code used to upload a file. Let me know whether it works. Only few lines are here.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.lang.Object;
    import java.util.*;
    import java.lang.String;
    import com.oreilly.servlet.MultipartRequest;
    public class FileUpload extends HttpServlet{
         public void doPost(HttpServletRequest req, HttpServletResponse res)throws
         ServletException, IOException{
         MultipartRequest multi=new MultipartRequest(req);     
         String file="file1";
         byte[] b=file.getBytes();
         InputStream in=null;
         BufferedInputStream bis=null;
         FileWriter fw=null;
    try{
         in=multi.getInputStream("file1");
    bis=new BufferedInputStream(in);
         File output=new File("/fileuploadtest");
         fw=new FileWriter(output);
              int i;
              i=bis.read();
              while (i != -1) {
    fw.write(i);
    i = bis.read();
         catch(IOException e){
              System.out.println("Exception=" +e);
    finally{
         try{
              if(in!=null)
              in.close();
              if(bis!=null)               
              bis.close();
              if(fw!=null)
              fw.close();
         catch(Exception e){
              System.out.println(e);
    This code is giving error as: cannot resolve symbol: class MultipartRequest
    Why is this happening?
    Pls let me know whether this code works or no and also i have written form.html.
    Can u pls tel me whether there are ways in which i can write a code to upload a file using servlets without using third party packages. Pls help.
    Also how should be the servlet mapping for this code.?
    Regards
    Message was edited by:
    user461713

  • What Is the best way to upload and download psd files from Photoshop to Photoshop Touch? [was:Re]

    What Is the best way to up load and down load psd files from desktop photo shop to photo shop touch? For on the go touch up or. I'm using psd files at 90 percent 300 depi when in photo shop on desktop. To ps touch

    Hi Bford225,
    I'd recommend using your favorite web browser and going to https://creative.adobe.com/files for uploading from the computer.
    Keep in mind tablet capabilities are much less than a computer, so large files might take a long time to download and be very system intensive to work on. Although you can import files up to 12 megapixels I'd recommend something more mid range, like 6 or 7 megapixels, ie 2880 x 2160 or 3072 x 2304.
    Also, PSD files are flattened when imported into Photoshop Touch.
    Hope that helps,
    -Dave 

  • Upload and Download Errror " File does not contain valid data"

    We are on the ECC 6.0 Unicode system.
    I dowloaded the Role from QA server and tried to upload into DEV box.
    I am getting the Error " File does not contain valid data".
    However, when I downloaded the Role, it was done successfully.
    Please let me know if anyone has that problem.
    Thanks,
    From
    PRANAV

    This is what I see here.
    DATE                                              20090716                                          131756RELEASE                                           700LOADED_AGRS                                       Z_BI_HR_REPORTING_FUNCTIONALAGR_DEFINE                                        210Z_BI_HR_REPORTING_FUNCTIONAL                                PTHAKER     20080523131557000000000000000PTHAKER     20090709142400000000000000000AGR_TCODES                                        210Z_BI_HR_REPORTING_FUNCTIONAL  TRRRMX                                             X 00000AGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000001S_RFC     T-BD90003500    U  O000004Authorization Check for RFC AccessAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000002S_RS_AUTH T-BD90003500    U  O000013BI Analysis Authorizations in RoleAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000003S_RS_COMP T-BD90003500    U  O000016Business Explorer - ComponentsAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000004S_RS_COMP1T-BD90003500    U  O000023Business Explorer - Components: Enhancements to the OwnerAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000005S_RS_FOLD T-BD90003500    U  O000029Business Explorer - Folder View On/OffAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000006S_RS_HIER T-BD90003500    U  O000032Data Warehousing Workbench - HierarchyAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000007S_RS_ODSO T-BD90003500    U  O000038Data Warehousing Workbench - DataStore ObjectAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000008S_RS_PARAMT-BD90003500    U  O000045Business Explorer - Variants in Variable ScreenAGR_1250                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000009S_TCODE   T-BD90003500    S  O000009Transaction Code Check at Transaction StartAGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000001S_RS_COMP T-BD90003500    RSZCOMPTP CKF                                                                             U  O000021AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000002S_RS_COMP T-BD90003500    RSZCOMPID *                                                                               U  O000020AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000003S_RS_COMP1T-BD90003500    RSZCOMPID ZHCM*                                                                           U  O000025AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000004S_TCODE   T-BD90003500    TCD       RRMX                                                                            S  O000010AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000005S_RS_HIER T-BD90003500    ACTVT     71                                                                              U  O000033AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000006S_RS_HIER T-BD90003500    RSHIENM   *                                                                               U  O000034AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000007S_RS_HIER T-BD90003500    RSIOBJNM  *                                                                               U  O000035AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000008S_RS_HIER T-BD90003500    RSVERSION *                                                                               U  O000036AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000009S_RS_PARAMT-BD90003500    PARAMNM   *                                                                               U  O000047AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000010S_RS_COMP T-BD90003500    RSINFOAREAZPA_ECM*                                                                        U  O000018AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000011S_RS_ODSO T-BD90003500    RSINFOAREAZPA_ECM*                                                                        U  O000040AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000012S_RS_COMP1T-BD90003500    RSZCOMPID ZPAOS*                                                                          U  O000025AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000013S_RS_ODSO T-BD90003500    ACTVT     03                                                                              U  O000039AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000014S_RS_COMP1T-BD90003500    RSZCOMPID ZPAPA*                                                                          U  O000025AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000015S_RS_ODSO T-BD90003500    RSODSOBJ  *                                                                               U  O000041AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000016S_RS_ODSO T-BD90003500    RSODSPART DATA                                                                            U  O000042AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000017S_RS_ODSO T-BD90003500    RSODSPART DEFINITION                                                                      U  O000042AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000018S_RS_ODSO T-BD90003500    RSODSPART EXPORTISRC                                                                      U  O000042AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000019S_RS_ODSO T-BD90003500    RSODSPART UPDATERULE                                                                      U  O000042AGR_1251                                          210Z_BI_HR_REPORTING_FUNCTIONAL  000020S_RS_COMP T-BD90003500    ACTVT     03                                                                              U  O000017AGR_1251

  • How to upload and download files using FTP to a server(webserver) in JSP

    I have to upload and download multiple files Of(size >5 MB)using FTP to a
    Server(webserver) in JSP
    how to do that ?

    Or he could create his own tag libraries, no? :)One supposes that, technically, one could create a taglib wrapper around an existing FTP library. There might be licensing issues with distributing that taglib wrapper.
    Of course, one could find the FTP RFC online, read it, and implement one's own FTP client implementation, complete with a tag library access point.

  • Uploading and downloading files in webdynpro java

    how to upload and download xl files in webdynpro java application .

    Hi ,
    Refer these links they maybe helpful to you
    You can check this sampple example from SDN
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40db4a53-41a9-2910-d4a2-9c28283f6658
    Uploading and Downloading Files In Web Dynpro Java
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f
    http://help.sap.com/saphelp_nw04/helpdata/en/43/85b27dc9af2679e10000000a1553f7/content.htm
    Uploading and Downloading Files In Web Dynpro Tables
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f
    Some more links regarding Uploading and DownLoading Files
    Uploading and downloading files
    Upload and Download file through RFC called by java
    Regards,
    Saleem

  • Facility to upload and download files

    I want to give a facility in my app to user for the uploading and downloading of files. How can I do that? Any example app?
    I also want an expert openion that is it advisible to keep the files (uploaded by user) in the files system? Or I should keep it in the datebase?
    I will be very thankful if someone can give the relative advantages and disadvanteages of both approches (File system or database)
    Thx,

    Hello,
    Sure, take a look at the packaged applications -
    http://www.oracle.com/technology/products/database/application_express/packaged_apps/packaged_apps.html#DOC_LIB
    John.
    http://jes.blogs.shellprompt.net
    http://apex-evangelists.com

  • Uploading and downloading files from a web app (Urgent!!)

    Hi everyone:
    I'm developing an application in PL/SQL to upload and download files from an HTML webpage. I congured the document table and the parameters necessary in the DAD of my application.
    when I upload the file using my webpage that file info is automatically uploaded to the doc table. This is as far as I have gotten.
    I need to do the following:
    - Place the uploaded file into a column in another table in my database as part of a text message (think of it as an email message), and delete the file from the doc table (as this is thought to be a temp table that holds the file when uploaded from my webpage)
    - Retreive the file so that it can be downloaded from another web page.
    The file can be a PDF, WORD DOC, etc...
    I now that I can do this with InterMedia but I haven't figured out how :(
    Can anyone please point me to an example or some documentation that can guide me through the process.
    DB VERSION: 8.1.7
    IAS VERSION: 1.0.2.2
    Thanks,
    Carlos Abarca

    The idea was for you to look at the code and get an idea of how to access the BLOB in the document table. IF you look at the procedure
    insert_new_photo( new_description IN VARCHAR2,
    new_location IN VARCHAR,
    new_photo IN VARCHAR2 )
    It shows how to access the blob that is stored in the document table. You can then copy this blob to your own table using the DBMS_LOB package.
    Hope this helps,
    Larry

Maybe you are looking for

  • Help.  Need to create 3 methods to do what main did originally.

    good afternoon. I am new to programming with java and would like to change the current code that I had written below to include 3 methods to do all the work originally done in main. I would like a method to handle the input, a method to do the subtot

  • Presets are missing since upgrading to Lightroom 5

    Since upgrading to Lightroom 5 a number of Adobe Presets I purchased are no longer available.  All of my HDR, Tilt Shift, Dragon as well as other presets are not available within the appliction even though they are still in the Preset folder. How do

  • Cant access my itnues cause it claims it was reintstalled wrong

    my itunes wont open cause stupid itunes claims it was not reinstalled correctly ive dealt with this stupid excuse so many times

  • MacBook Pro can't print through Time Capsule

    I seem to be completely unable to get my 15" MacBook Pro to print to an Epson Stylus Photo R260 printer connected to a Time Capsule. I send documents to the printer, and the print queue indicates that it prints, but nothing comes out. The issue seems

  • What Piece of Hardware Affects What, Exactly?

    Hi, I haven't been able to find out a definitive, reliable answer for this stuff anywhere. It seems like there's plenty of pseudo-science and marketing hype telling me I need to just spend a lot of money. SO: When editing in Final Cut Pro, what do th