Preceeding zeroes while excel upload and download

Hi,
I am uploading some data from excel into an internal table,processing it and then downloading it again in excel.
For Excel Upload I am using CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
For Excel Download I am using GUI_DOWNLOAD.
But the problems is when the data is like 01 it is downloading it as 1 in the excel.The user don't want to do any changes after downloading it to the excel and want the data 01 to be dowloaded as 01 itself and not as 1.
We can format it in excel but the user is not willing for that.Any possibility that we can handle it in the program.
Thanks,
K.Kiran.

You have to use OLE technique for the same....that will solve your case.
supposae i want to make the 5th , 6th and 7th coloumn , as character format.
The below scenario will help.
collect the contents of the excel in  it[] ,
  DESCRIBE TABLE it[] LINES wf_it_line.
  wf_it_line = wf_it_line + 8.
  CLEAR : wf_cellx, wf_celly, wf_cellr.
  CALL METHOD OF wf_excel 'Cells' = wf_cellx
  EXPORTING
   #1 = 8
   #2 = 5.
  CALL METHOD OF wf_excel 'Cells' = wf_celly
  EXPORTING
   #1 = wf_it_line
   #2 = 7.
  CALL METHOD OF wf_excel 'Range' = wf_cellr
   EXPORTING
#1 = wf_cellx
#2 = wf_celly.
  SET PROPERTY OF wf_cellr 'NumberFormat' = '@' .
this will change the format of the excel.
then call the below method
  CALL METHOD cl_gui_frontend_services=>clipboard_export
      IMPORTING
        data                 = it[]
      CHANGING
        rc                   = l_rc
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
     not_supported_by_gui = 3
        OTHERS               = 4.
  CALL METHOD OF wf_excel 'Cells' = wf_cell1
    EXPORTING
     #1 = 1
     #2 = 1.
  CALL METHOD OF wf_excel 'Cells' = wf_cell2
    EXPORTING
     #1 = 1
     #2 = 1.
  CALL METHOD OF wf_excel 'Range' = wf_range
    EXPORTING
     #1 = wf_cell1
     #2 = wf_cell2.
  CALL METHOD OF wf_range 'Select'.
  CALL METHOD OF wf_worksheet 'Paste'.
then call the method 'SAVEAS' to save the excel.
Edited by: Rudra Prasanna Mohapatra on Jan 22, 2009 5:47 AM

Similar Messages

  • Function module upload and download

    Hello All,
    while using Upload and download function modules, how to avoid popup for providing file path, as am already passing it from reading from the selections screen. while running again i dont want to get the popup asking file path.
    thx in advance,
    sippy.

    Hi,
    You can try with
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
        EXPORTING
          FILENAME        = I_DIR
          READ_BY_LINE    = 'X'     " FILETYPE = 'ASC'
        CHANGING
          DATA_TAB        = IT_TEXTO
        EXCEPTIONS
          FILE_OPEN_ERROR = 1
          FILE_READ_ERROR = 2
          BAD_DATA_FORMAT = 8
          OTHERS          = 19.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
      EXPORTING
       BIN_FILESIZE              =
        FILENAME                  = I_DIR2
       FILETYPE                  = 'ASC'
       APPEND                    = SPACE
       WRITE_FIELD_SEPARATOR     = SPACE
       HEADER                    = '00'
       TRUNC_TRAILING_BLANKS     = SPACE
      CHANGING
        DATA_TAB                  = IT_TEXTO.
    Best Regards
    Ana

  • Upload and Download of Purchase Orders - Account Assignments problem

    Hi SRM Gurus,
    While downloading the SRM PO into Excel format, Account Assignment is not being downloaded.
    Our requirement is, To add many line items in the downloaded excel and subsequently upload to SRM. However the file structure readability is very poor even after installed Add In given by SAP. Can anyone help me in providing a solution, so that the users can be able to insert the line items and upload.
    Thanks & Regards,
    Ramkumar

    Hi
    <u>Please read this -></u>
    <b>Please see the note mentioned below.</b>
    <u>
    Note 734060 SRM:Upload and Download of Documents using MS Excel
    Note 734946 SRM: Restriction on upload and download.</u>
    <b>Alternativey, try using BBP_DOWNLOAD_BADI in SE18 Transaction.</b>
    Upload PO from XML file in SRM
    Upload + Download in Bid invitation
    Re: Contract Upload to New System
    Re: Bid download to Excel
    Re: Upload new Contracts in SRM4.0
    Contract Upload Scenario
    Re: Upload of contracts from text file or spreadsheet
    Regards
    - Atul

  • 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

  • Uploading and downloading blobs without wwv_flow_files

    Hi,
    I am currently working on oracle 10g database and application express.
    i went throu the material to upload and download images, pdf from a htmldb book.
    it was excellent material. but the book only gave example about loading and downloading images, pdf through flows_files.wwv_flow_files view.
    it seemed like we can only d/l the pdf, images and display on htmldb report only throu flows_files.wwv_flow_files view, as in the case of the script below
    select
       wff.id, htf.anchor( 'p?n=' || wff.id, wff.filename ) filename_1,
       wff.filename filename_2, ed.abstract abstract
    from
       wwv_flow_files wff, easy_document ed
    where
       wff.name = ed.name;but is there a way to load and download images, pdfs from my own tables without the involvement of flows_files schema.
    if then how can i modify the above code to get the pdf from the following table
    TableA (vessel number, cruise number, pdf blob)
    here for every (vessel, cruise) combination there is a pdf.
    how can i get this pdf displayed in my htmldb report.
    Can someone guide me please.
    Thanks,
    Philip.

    Hi,
    I tried the document link you gave and it looks like, i can directly download pdfs from my own tables without needding to upload to wwv_flow_files_objecst$ table.
    i modified the procedure in the document accroding to my requirements and it worked.
    in my page i show a grid with the parameters and the pdf documentname as download link.
    when i click on the link a popup window with the option to save or open comes up.
    but the popup window shows the filename as my procedure name through which i pass the id for the pdf document instaed of the filename which is shown as download link on the page.
    How can i change this popup window filename to the default file name shown in the download link.
    so that everytime i select the parameters, the page shows the pdf filename as link and on clicking the link the popup window should be able to show the same name shown as link.
    i think this can be set either at the procedure level or at the page level.
    and this is the following contents of the procedure
    --        SET UP HTTP HEADER
                   -- use an NVL around the mime type and
                   -- if it is a null set it to application/octect
                   -- application/octect may launch a download window from windows
                   owa_util.mime_header( nvl('PDF','application/octet'), FALSE );
                    -- set the size so the browser knows how much to download
                     htp.p('Content-length: ' || B_LEN);
                    -- the filename will be used by the browser if the users does a save as
    -- htp.p('Content-Disposition:  attachment; filename="'||'CR'||VES||CRU||'.PDF'|| '"');
                    -- close the headers           
                    owa_util.http_header_close;
                    -- download the BLOB
                    wpg_docload.download_file( BREP );and this is what i did at the page level. for that particular column i went to link option and the foll is what i gave:
    Link Text: CR#VESSEL##CRUISE#.PDF
    Link Attributes: target="_blank"
    URL: #OWNER#.PROC_DOWNLOAD_PDFS?V=#VESSEL#&C=#CRUISE#
    Here the link text is the filename that i wanted to show when saving the file.
    Can someone guid eme please.
    Thanks,
    Philip.

  • Reg :File upload and download from client machine

    hi..
    anyone help me the way that how to upload and download word
    document file from client machine.. i am using j2eeserver1.4 in linux..
    i want upload file from client machine(windows) to server(linux.) please
    help me . tell me idea regarding..
    i have tried this coding.. but i can transfer txt file. only. when i upload mirosoft word file.. it will open with some ascii values with actual content.
    <!-- upload.jsp -->
    <%@ page import="java.io.*" %>
    <%String contentType = request.getContentType();
    String file = "";
    String saveFile = "";
    FileOutputStream fileOut = null;
    if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
    DataInputStream in = new DataInputStream(request.getInputStream());
    int formDataLength = request.getContentLength();
    byte dataBytes[] = new byte[formDataLength];
    int byteRead = 0;
    int totalBytesRead = 0;
    while (totalBytesRead < formDataLength)
    byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
    totalBytesRead += byteRead;
    try { 
    file = new String(dataBytes);
    saveFile = file.substring(file.indexOf("filename=\"") + 10);
    saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
    saveFile = saveFile.substring(saveFile.lastIndexOf("/") + 1,saveFile.indexOf("\""));
    int lastIndex = contentType.lastIndexOf("=");
    String boundary = contentType.substring(lastIndex + 1,contentType.length());
    int pos;
    pos = file.indexOf("filename=/" + 1);
    pos = file.indexOf("\n", pos) + 1;
    pos = file.indexOf("\n", pos) + 1;
    pos = file.indexOf("\n", pos) + 1;
    int boundaryLocation = file.indexOf(boundary, pos) - 4;
    int startPos = ((file.substring(0, pos)).getBytes()).length;
    int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
    String folder = "/tmp/uploads/";
    fileOut = new FileOutputStream(folder + saveFile);
    fileOut.write(dataBytes);
    fileOut.write(dataBytes, startPos, (endPos - startPos));
    fileOut.flush(); } catch(Exception e) {  out.print(e);
    } finally
    {  try
    {fileOut.close();
    }catch(Exception err)
    %>
    please which package will help me to upload word document file with no errror. send me how can use in ftp.. send me some sample program..
    Regards..
    New User M.Senthil..

    Hi,
    Well,i don't know whether if this helps people here are not.
    It is always a good practise to do it via Servlet and then download content.
    The adavantage of doing this is
    1). You may not need to pack the downloadable with the .war which you ultimately genrate which ceratinly help us in terms of faster deployment.
    3). You may update the new content just by moving a file to the backup folder.
    2).One may definately download the content irrespective to the content/file.
    Hope example below helps..
    Configurations:
    In the above example we are assuming that we placing all downlodable file in D:/webapp/downlodables/ and you have configured the same path as a init param with the name "filePath" in your web.xml.
    something like the one below.
    <servlet>
        <servlet-name>DownloadServlet</servlet-name>
        <servlet-class>com.DownloadServlet</servlet-class>
        <init-param>
           <param-name>filePath</param-name>
           <param-value>D:/webapp/downlodables/</param-name>
           <!--Could use any backup folder Available on your Server-->
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>DownloadServlet</servlet-name>
        <url-pattern>/downloadFile</url-pattern>
    </servlet-mapping>DownloadServlet.java:
    ==================
    package com;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import javax.activation.MimetypesFileTypeMap;
    *@Author RaHuL
    /**Download Servlet
    *  which could be accessed downloadFile?fid=fileName
    *  or
    *  http://HOST_NAME:APPLN_PORT/ApplnContext/downloadFile?fid=fileName
    public class DownloadServlet extends HttpServlet{
      private static String filePath = new String();
      private static boolean dirExists = false;
      public void init(ServletConfig config){
          // Acquiring Backup Folder Part
          filePath = config.getInitParameter("filePath");
          dirExists = new File(filePath).exists();      
      private void processAction(HttpServletRequest request,HttpServletResponse response) throws Exception{
           // Some Authentication Checks depending upon requirements.
           // getting fileName which user is requesting for
           String fileName = request.getParameter("fid");
           //Building the filePath
           StringBuffer  tFile = new StringBuffer();
           tFile.append(filePath);    
           tFile.append("fileName"); 
           boolean exists = new File(tFile.toString()).exists();
           // Checking whether the file Exists or not      
           if(exists){
            FileInputStream input = null;
            BufferedOutputStream output = null; 
            int contentLength = 0;
            try{
                // Getting the Mime-Type
                String contentType = new MimetypesFileTypeMap().getContentType(tFile.toString());          
                input = new FileInputStream(tFile.toString());
                contentLength = input.available();
                response.setContentType(contentType);
                response.setContentLength(contentLength);
                response.setHeader("Content-Disposition","attachment;filename="+fileName);
                output = new BufferedOutputStream(response.getOutputStream());
                while ( contentLength-- > 0 ) {
                   output.write(input.read());
                 output.flush();
              }catch(IOException e) {
                     System.err.println("Exception Occured:"+e.getMessage());
                 System.err.println("Exception Localized Message:"+e.getLocalizedMessage());
              } finally {
                   if (output != null) {
                       try {
                          output.close();
                      } catch (IOException ie) {
                          System.err.println("Exception Occured:"+e.getMessage());
                             System.err.println("Exception Localized Message:"+e.getLocalizedMessage());                      
           }else{
             response.sendRedirect("/errorPage.html");
      public void doPost(HttpServletRequest request,HttpServletResponse response) throws Exception{       
            processAction(request,response); 
      public void doGet(HttpServletRequest request,HttpServletResponse response) throws Exception{
            processAction(request,response); 
    NOTE: Make sure You include activations.jar in your CLASSPATH b4 trying the code.
    therefore,if you have something like above set as your application enviroment in the above disccussed
    can be done by just giving a simple hyper link like
    <a href="downloadFile?fid=fileName.qxd" target="_blank">Download File</a>REGARDS,
    RaHuL

  • File Upload and Download Upto 150MB

    Hi,
    I have a new requirement in application, Where user will be uploading and download file upto 150MB which is the best method to do need a suggestion which will not affect the database performance.
    Need a best way to do in apex to upload and download file.
    Thanks
    Sudhir

    I am also having same problem, my system is restricting the data to 60.1MB while downloading the file. How to solve this. any body have any answer.

  • Class to upload and download images

    is there any class which we can use to upload and download images
    only 1 restrain while downloadin it should NOT ask where to download
      it should directly go to desktop.
         please help
    Edited by: Amit Sawant on Dec 20, 2007 10:45 AM

    You have to call the Static methods of the Class: Cl_GUI_FRONTEND_SERVICES.
    for UPLOAD:
    call Method Cl_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    for DOWNLOAD:
    call Method Cl_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    You can open this Class Cl_GUI_FRONTEND_SERVICES in Class builder SE24 and find these methods
    Also refer to these links:
    cl_gui_frontend_services
    CL_GUI_FRONTEND_SERVICES
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    Reward points if found helpful...
    Cheers,
    Chandra Sekhar.

  • Upload and Download through the same button toolbar Spreadsheet

    Hello,
    Does anyone know if I can set up the two processes: Uploading and downloading Data Inside the Excel toolbar?
    Web ADI defines the Oracle tap where the Upload and Download options are. Where Web ADI defines the Oracle tap?
    Can I modify that menu and unify in the same button the upload and download processes.
    My client wants to see the refreshed data inside Oracle without pushing Uploading Data and pushing again Downloading Data.
    Thanks in advance,
    Carmen.

    Duplicate as this thread:
    Upload and Download through same Excel Sheet
    //Nitin

  • 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){
         }

  • WRT400N Upload and Download Speeds

    I have a WRT400N router. I have a network set up where I am physically connected to the router while my two room mates have a wireless connection. When I test my connection I have a download speed of 25 Mb/s and an upload of about 2 Mb/s. My room mates however have a download speed of .5 Mb/s and upload of about .5 Mb/s. They are getting full signal strength from my router, so I am not sure what the problem is. What is the problem and how do I fix this? They should be getting much faster upload and download speeds. 

    After a firmware upgrade, you must reset the router to factory defaults, then setup the router again from scratch.  If you have not done this since the last firmware upgrade, then please do this now and see if it corrects your problem.  If you saved a router configuration file, DO NOT use it  ---  you must setup the router from scratch.
    If the above does not correct your problem, then the most likely cause is simply a poor wireless connection.  This can occur even if your computer shows "5 bars" or "full signal strength".
    There are many causes for poor wireless connections, and many solutions:
    First of all, give your network a unique SSID. Do not use "linksys". If you are using "linksys" you may be trying to connect to your neighbor's router. Also set "SSID Broadcast" to "enabled". This will help your computer find and lock on to your router's signal.
    If your problem is that you are getting poor speed between your wireless n router and wireless n adapter, in the router, make sure the "Radio Band" is set to "Wide".
    Poor wireless connections are often caused by radio interference from other 2.4 GHz devices. This includes wireless phones, wireless baby monitors, microwave ovens, wireless mice and keyboards, wireless speakers, and your neighbor's wireless network. In rare cases, Bluetooth devices can interfere. Even some 5+ GHz phones also use the 2.4 Ghz band. Unplug these devices, and see if that corrects your problem.
    In your router, try a different channel. There are 11 channels in the 2.4 GHz band. Usually channel 1, 6, or 11 works best. Check out your neighbors, and see what channel they are using. Because the channels overlap one another, try to stay at least +5 or -5 channels from your strongest neighbors. For example, if you have a strong neighbor on channel 9, try any channel 1 through 4. For wireless n, make sure your standard and wide bands are at least 2 channels apart. For example try standard band on channel 11, and wide band channel 9.
    Also, try to locate the router about 4 to 6 feet above the floor, in an open area. Do not locate it behind your monitor or near other computer equipment or speakers. The antenna, if external, should be vertical.
    Also, in the computer, go to your wireless software, and go to "Preferred Networks" (sometimes called "Profiles" ). There are probably a few networks listed. Delete any network named "linksys". Also delete any network that you do not recognize, or that you no longer use. If your current network is not listed, enter its info (SSID, encryption (if any), and key (if any) ). Then select your current network and make it your default network, and set it to automatic login. You may need to go to "settings" to do this, or you may need to right click on your network and select "Properties" or "settings".
    If the above does not fix your problem, download and install the latest driver for your computer's wireless adapter.
    Some users have reported improved wireless performance by switching to WPA encryption.
    If you continue to have problems, try the following:
    For wireless n routers, try setting the "n Transmission Rate" to 162 Mbps, and the (wireless g) "Transmission Rate" to 54 Mbps.
    If you still have trouble, download and install the latest firmware for your router. After a firmware upgrade, you must reset the router to factory defaults, then setup the router again from scratch. If you saved a router configuration file, DO NOT use it.
    Hope this helps.

  • About "Upload and download files from ADF into blob type colum."

    hi
    Using JDeveloper 10.1.3.3.0 I have tried the example available for download from this blog post by Jakub Pawlowski:
    "Upload and download files from ADF into blob type colum."
    at http://kuba.zilp.pl/?id=1
    First a thank you to Jakub for this interesting example.
    I have a question about a PDF file that I uploaded using the example.
    The file has a size of 10445518 bytes.
    After I upload that file, the blob column has a value with a size of 10445516 bytes, 2 bytes less.
    SQL> select file_name, dbms_lob.getlength(stored_file) from blob_table;
    FILE_NAME
    DBMS_LOB.GETLENGTH(STORED_FILE)
    ADF-DeveloperGuide-4GL-B25947_01.pdf
                           10445516If I download that file using the example, it has the same size as the blob value, 10445516 bytes.
    If I open the downloaded file, using Adobe Reader 8.1.1, it first shows this message:
    "The file is damaged but is being repaired."
    After that, there is not problem using the PDF file in Adobe Reader.
    I have tried this with both Internet Explorer 6 and Firefox 2.0.0.11.
    I have also tried this with other (smaller) files, and those upload and download correctly.
    question:
    Why are those 2 bytes lost during upload?
    many thanks
    Jan Vervecken

    Hi!
    I can only post you my code that works for me and as I said I had same problems but can't remember what solved them. My code:
      public void fileUploaded(ValueChangeEvent event)
        FacesContext fc = FacesContext.getCurrentInstance();
        UploadedFile file = (UploadedFile) event.getNewValue();
        if (file != null && file.getLength() > 0)
          // here I have some messages written and a call to the method on AM to save the uploaded file to the DB
      private BlobDomain newBlobDomainForInputStream(InputStream in)
        throws SQLException, IOException
        BlobDomain loBlob = new BlobDomain();
        OutputStream out = loBlob.getBinaryOutputStream();
        writeInputStreamToWriter(in, out);
        in.close();
        out.close();
        return loBlob;
      private static void writeInputStreamToWriter(InputStream in,
                                                   OutputStream out)
        throws IOException
        byte[] buffer = new byte[8192];
        int charsRead = 0;
        while ((charsRead = in.read(buffer, 0, 8192)) != -1)
          out.write(buffer, 0, charsRead);
       * Launch the upload - see fileUploaded() for actual upload handling.
       * @return null navigation event - we stay on this page
      public String UploadButton_action()
        if (this.getMyInputFile().getValue() == null)
          FacesContext context = FacesContext.getCurrentInstance();
          FacesMessage message =
            new FacesMessage(FacesMessage.SEVERITY_WARN, JSFUtils.getStringFromBundle("fileupload.emptyfielderror"),
                             null);
          context.addMessage(this.getMyInputFile().getId(), message);
        return null;
       * Setter for inputFile UI Component.
       * @param inputFile inputFile UI component
      public void setMyInputFile(CoreInputFile inputFile)
        this.myInputFile = inputFile;
       * Getter for inputFile UI Component.
       * @return inputFile UI component
      public CoreInputFile getMyInputFile()
        return myInputFile;
      }fileUploaded is a valueChangeListener on inputFile and UploadButton_action is as the name says the action for upload button.
    Hope this helps. If not, than your problem is probably not the same as mine was, although the message about file corrupted was the same.
    Next thing you can check in this case is if your file exceeds max file upload size. I don't know the exact default value, but if the file is too long I think this upload logic will upload only a part of the file and save it to the DB which can also lead to the same file corrupted error.
    You can set the max upload value in web.xml like this:
    <context-param>
    <!-- Maximum memory per request (in bytes) -->
    <param-name>oracle.adf.view.faces.UPLOAD_MAX_MEMORY</param-name>
    <!-- Use 5000K -->
    <param-value>5120000</param-value>
    </context-param>
    <context-param>
    <!-- Maximum disk space per request (in bytes) -->
    <param-name>oracle.adf.view.faces.UPLOAD_MAX_DISK_SPACE</param-name>
    <!-- Use 10,000K -->
    <param-value>15360000</param-value>
    </context-param>

  • How to Upload and Download Files

    Dear Friends
    I want to write code for Upload and Download file ( Group of Files). Please Guide me the right way I have a few java files and i have compiled that but i donot know how to run that file and i am stranger to java also.
    Please send me reply and sugessest me.
    my email id is [email protected]
    Amogh

    I have write a upload code, but the code can deal with txt onle, it can not deal with bmp or doc, what the matter?
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Upload extends HttpServlet {
         String rootPath;
         static final int MAX_SIZE = 102400;
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         public void doGet(HttpServletRequest request,HttpServletResponse response)
         throws ServletException,IOException
              response.setContentType("text/html");
              PrintWriter out = new PrintWriter (response.getOutputStream());
              out.println("<html>");
              out.println("<head><title>Servlet1</title></head>");
              out.println("<body><form ENCTYPE=\'multipart/form-data\' method=post action=''><input type=file enctype=\'multipart/form-data\' name=filedata>");
              out.println("<input type=submit></form>");
              out.println("</body></html>");
              out.close();
         public void doPost(HttpServletRequest request,HttpServletResponse response)
              ServletOutputStream out=null;
              DataInputStream in=null;
              FileOutputStream fileOut=null;
              rootPath = "C:\\upload\\tmp\\";          //The directory to save the target file.
              try
                   response.setContentType("text/plain");
                   out = response.getOutputStream();
              catch (IOException e)
                   System.out.println("Error getting output stream.");
                   System.out.println("Error description: " + e);
                   return;
         try
              String contentType = request.getContentType();
              if(contentType != null && contentType.indexOf("multipart/form-data") != -1)
                   in = new DataInputStream(request.getInputStream());
                   int formDataLength = request.getContentLength();
                   byte dataBytes[] = new byte[formDataLength];
                   int bytesRead = 0;
                   int totalBytesRead = 0;
                   int sizeCheck = 0;
                   String sourceFileName = "";
                   String targetFileName = "";
                   while (totalBytesRead < formDataLength)
                        sizeCheck = totalBytesRead + in.available();
                        if (sizeCheck > MAX_SIZE)
                             out.println("Sorry, file is too large to upload.");
                             return;
                        bytesRead = in.read(dataBytes, totalBytesRead, formDataLength);
                        totalBytesRead += bytesRead;
                   String file = new String(dataBytes);
                   dataBytes = null;
                   int lastIndex = contentType.lastIndexOf("=");
                   String boundary = contentType.substring(lastIndex+1, contentType.length());
                   //File Content
                   //out.println("File content: " + file);
                   if (file.indexOf("name=") > 0)
                        int fileNameStart = 0;
                        int fileNameEnd = 0;
                        fileNameStart = file.indexOf("filename=\"");
                        fileNameEnd = file.indexOf("Content-Type:");
                        sourceFileName = file.substring(fileNameStart + 10, fileNameEnd - 3);
                        //Source File
                        out.println("Source file: " + sourceFileName);
                   String successPage="";
                   if (file.indexOf("name=\"SuccessPage\"") > 0)
                        successPage = file.substring(file.indexOf("name=\"SuccessPage\""));
                        successPage = successPage.substring(successPage.indexOf("\n")+1);
                        successPage = successPage.substring(successPage.indexOf("\n")+1);
                        successPage = successPage.substring(0,successPage.indexOf("\n")-1);}
                        String overWrite;
                        if (file.indexOf("name=\"OverWrite\"") > 0)
                             overWrite = file.substring(file.indexOf("name=\"OverWrite\""));
                             overWrite = overWrite.substring(
                             overWrite.indexOf("\n")+1);
                             overWrite = overWrite.substring(overWrite.indexOf("\n")+1);
                             overWrite = overWrite.substring(0,overWrite.indexOf("\n")-1);
                        else
                             overWrite = "false";
                        String overWritePage="";
                        if (file.indexOf("name=\"OverWritePage\"") > 0)
                             overWritePage = file.substring(file.indexOf("name=\"OverWritePage\""));
                             overWritePage = overWritePage.substring(overWritePage.indexOf("\n")+1);
                             overWritePage = overWritePage.substring(overWritePage.indexOf("\n")+1);
                             overWritePage = overWritePage.substring(0,overWritePage.indexOf("\n")-1);
                        targetFileName = sourceFileName.substring(sourceFileName.lastIndexOf("\\") + 1);
                        targetFileName = rootPath + targetFileName;
                        //Target File:
                        out.println("Target file: " + targetFileName);
                        int pos; //position in upload file
                        pos = file.indexOf("filename=");
                        pos = file.indexOf("\n",pos)+1;
                        pos = file.indexOf("\n",pos)+1;
                        pos = file.indexOf("\n",pos)+1;
                        int boundaryLocation = file.indexOf(boundary,pos)-4;
                        file = file.substring(pos,boundaryLocation);
                        File checkFile = new File(targetFileName);
                        if (checkFile.exists())
                             if (!overWrite.toLowerCase().equals("true"))
                                  if (overWritePage.equals(""))
                                       out.println("Sorry, file already exists.");
                                  else
                                       //redirect client to OverWrite HTML page
                                       response.sendRedirect(overWritePage);
                                  return;
                        File fileDir = new File(rootPath);
                        if (!fileDir.exists())
                             fileDir.mkdirs();
                        fileOut = new FileOutputStream(targetFileName);
                        fileOut.write(file.getBytes(),0,file.length());
                        if (successPage.equals(""))
                             out.println("File written to: " + targetFileName);
                        else
                             response.sendRedirect(successPage);
                        else //request is not multipart/form-data
                             out.println("Request not multipart/form-data.");
                   catch(Exception e)
                        try
                             System.out.println("Error in doPost: " + e);
                             out.println("An unexpected error has occurred.");
                             out.println("Error description: " + e);
                        catch (Exception f) {}
                   finally
                   try
                        fileOut.close(); //close file output stream
                   catch (Exception f) {}
                   try
                        in.close(); //close input stream from client
                   catch (Exception f) {}
                   try
                        out.close(); //close output stream to client
                   catch (Exception f) {}
    }

  • 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

  • Upload and download a PDF in BSP

    Hi All,
    I need to do the following funtionalityin BSP (business server page ).
    1)upload and download a PDF
    Pls anyone help me by providing the necessary code to do this .
    Thanks in Advance
    Rizwan

    Hi,
    This link is useful for U
    http://help.sap.com/saphelp_nw04/helpdata/en/eb/8c683c8de8a969e10000000a114084/content.htm
    http://wiki.sdn.sap.com/wiki/display/BSP/HandlingBinaryData
    Regards
    kk

Maybe you are looking for

  • What are the required settings for Quality Certificate

    Hi Team What are the required settings for Quality Certificate for Raw material from vendor. This is my RR - Result Recording  for inspection lot. Please sugget me T-Code to view this. Can I see say for 6-9 months RR done insp. lot. Thanks

  • System Recovery that worked for me.

    I've read soooooooo many complaints about Toshiba purchasers being unable to restore their laptops with their XP Recovery Discs.  The usual answer from the experts on this site is that you need a new disc or your DVD drive is defective.  Of course, y

  • Export mac os x server mail accounts to exchange server

    Hi ! I have a customer with a G5 xserve running 10.4.11 - it was set as the mail server. It had approx 40 windows users using IMAP accounts This has now been bypassed by new IT people coming in and installing an exchange server. I am now being asked

  • In my standby dataguard configuration

    Hi All, I observed one strange thing in my database is that my archives are getting shipped regularly to DR site but in night time only it starts to getting applied. Some time, it starts to apply but its very slow. I confirmed with network team and t

  • Where is the lock icon when i am ordering something on line

    when i order something on line with internet explorer a lock icon comes up to let me know i am secure how does firefox work in this case?