Session tracking for File Upload Servlet

Hey Friends,
I am developing a File Upload servlet and I need your help in certain matters .I have taken the servlet code from java-edge.com and am modifying it to give custom behaviour.I have a main page for upload (form upload)(lets call it form 1).If the file to be uploaded already exists on the server then a page is generated by the server saying that file already exists.(form 2)Now it is here(in form 2) that I want to provide an extra button which when submitted would recall the same servlet /or maybe another one and would provide the user for overriding the existing file.
Now as per the code I would set the Override flag to be false in the second form and false in the main form .
Given the case that it is a form based uploading servlet how do I maintain the user session when going to the next form or how do i pass the variables of the first form into second form .
I am also facing another problem that is how do i manage multiple file uploads at a time .This basic system allows only one file per upload .
P.S If someone could also throw some light on how to use the com.oreilly servlet (the latest version) it would be lovely but for now I want to focus on developing the current one

Hi Jocelyn,
I want to apologize firstly for the delay in my response.
I was seriously bogged down due to certain circumstances and so couldnt reply.Thanks a million for your prompt reply.I'll post the Html content here and you will find the servlet code as is at the following U.R.L
http://www.java-edge.com/Viewcode.asp?Value=serv012
Form1:
<HTML>
<HEAD>
<TITLE> Upload </TITLE>
</HEAD>
<BODY >
<h2>Upload Your File!</h2>
<form ENCTYPE="multipart/form-data" action="http://localhost:8080/servlet/Upload" method=post>
click <b> browse </b>to select the file <br>
<b> File:</b>
<input type="FILE" name="Filename" value="" MAXLENGTH=255 size=50><br>
Click here to upload!<input type=submit value=Upload>
<input type=hidden name=Directory value="G:/Workspace/Upload/">
<input type=hidden name=SuccessPage value="G:/Workspace/successpage.html">
<input type=hidden name="OverWrite" value="false">
<input type=hidden name="OverWritePage" value="">
</form>
</BODY>
</HTML>
Form 2
<HTML>
<HEAD>
<TITLE> Upload </TITLE>
</HEAD>
<BODY >
<h2>Upload Your File!</h2>
<form ENCTYPE="multipart/form-data" action="http://localhost:8080/servlet/Upload" method=post>
click <b> browse </b>to select the file <br>
<b> File:</b>
<input type="FILE" name="Filename" value="" MAXLENGTH=255 size=50><br>
Click here to upload!<input type=submit value=Upload>
<input type=hidden name=Directory value="G:/Workspace/Upload/">
<input type=hidden name=SuccessPage value="G:/Workspace/successpage.html">
<input type=hidden name="OverWrite" value="true">
<input type=hidden name="OverWritePage" value="G:/Workspace/overwritepage.html">
</form>
</BODY>
</HTML>
Now in Form 2 I would add another button which when clicked would prompt the user if he wishes to overwrite the page.
I am also posting the servlet code although I am sure u would prefer reading the one on the site
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Upload extends HttpServlet
static final int Max = 102400;// max. size of the file can be 100K
String path;// stores path
String msg;// store message of success
//init method is called when servlet is first loaded
public void init(ServletConfig config)throws ServletException
super.init(config);
if(path == null)
path = "G:/Workspace/Upload/";
if(msg == null)
msg = "File successfully uploaded. Check out!";
public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException
ServletOutputStream sos = null;
DataInputStream dis = null;
FileOutputStream fos = null;
try
resp.setContentType("text/plain");// return type of response is being set as plain
sos = resp.getOutputStream();// gets handle to the output stream
catch(IOException e)
System.out.println(e);
return;
try
String contentType = req.getContentType();// gets client's content type that should be multipart/form-data
if(contentType!=null && contentType.indexOf("multipart/form-data")!= -1)
     // gets handle to the input stream to get the file to be uploaded from client
     dis = new DataInputStream(req.getInputStream());
     // gets length of the content data
     int Length = req.getContentLength();
     if(Length>Max)// length of the content data is compared with max size set
     sos.println("sorry! file too large");
     sos.flush();
     return;
     //to store the contents of file in byte array
     byte arr[] = new byte[Length];
     int dataRead = 0;
     int totalData = 0;
     while(totalData <Length)
     dataRead = dis.read(arr,totalData,Length);
     totalData += dataRead;
     String data = new String(arr);//byte array converted to String
     arr = null;
     // gets boundary value
     int lastIndex = contentType.lastIndexOf("=");
     String boundary = contentType.substring(lastIndex+1,contentType.length());
     String dir = "";
     if(data.indexOf("name=Directory")>0)// the type ""Directory"" is searched in the web page
     dir = data.substring(data.indexOf("name=Directory"));
     //gets directory
     // the directory higher in the directory tree cannot be selected
     if(dir.indexOf("..")>0)
     sos.println("Error- the directory higher in the directory tree cannot be selected");
     return;
     String successPage="";
     if(data.indexOf("name=\"SuccessPage\"")>0)// the type ""SuccessPage"" is searched in the web page
     successPage =data.substring(data.indexOf("name=\"SuccessPage\""));
     // gets successpage
     String overWrite="";
     if(data.indexOf("name=\"OverWrite\"")>0)// the type ""Overwrite"" is searched in the web page
     overWrite =data.substring(data.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);//gets overwrite flag
     else
     //overWrite = "false";
     String overWritePage ="";
     if(data.indexOf("name=\"OverWritePage\"")>0)// the type ""OverwritePage"" is searched in the web page
     // ensures same file is not uploaded twice
     overWritePage =data.substring(data.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);// // gets overwritepage
     //gets upload file name
     String file =data.substring(data.indexOf("filename=\"")+10);
     file = file.substring(0,file.indexOf("\n"));
     file = file.substring(file.lastIndexOf("\\")+1,file.indexOf("\""));
     int position;//upload file's position
     position =data.indexOf("filename=\"");//find position of upload file section of request
     position =data.indexOf("\n",position)+1;//find position of content-disposition line
     position =data.indexOf("\n",position)+1;//find position of content-type line
     position =data.indexOf("\n",position)+1;//find position of blank line
     int location =data.indexOf(boundary,position)-4;//find position of next boundary marker
     data =data.substring(position,location);// uploaded file lies between position and location
     String fileName = new String(path + dir + file);// the complete path of uploadad file
     File check = new File(fileName);
/*************************CASE OVERRIDE ************************************/
     //String overwrite=req.getParameter("OverWrite");
     if(check.exists())// checks for existence of file
          if(overWrite.equals("false"))
                    if(overWritePage.equals(""))
                    sos.println("Sorry ,file already exists");
                    //return;
                    else
                    //overWritePage="G:/Workspace/overwritepage.html";
                    fos = new FileOutputStream(fileName);
                    fos.write(data.getBytes(),0,data.length());
                    //resp.sendRedirect(overWritePage);
                    sos.println("File Overridden");
          //return;
     File checkDir = new File(path + dir);
     if(!checkDir.exists())//checks for existence of directory
     checkDir.mkdirs();
fos = new FileOutputStream(fileName);
fos.write(data.getBytes(),0,data.length());
sos.println("File successfully uploaded");
if(check.exists())
          if(overWrite.equals("true"))
               fos = new FileOutputStream(fileName);
               fos.write(data.getBytes(),0,data.length());
               if(successPage.equals(""))
               sos.println(msg);
               sos.println("File successfully uploaded");// if success HTML page URL not received
               else
               successPage="G:/Workspace/successpage.html";
               resp.sendRedirect(successPage);
     else// incase request is not multipart
     sos.println("Not multipart");
}//END OF TRY BLOCK
catch(Exception e)
          try
          System.out.println(e);
          sos.println("unexpected error");
          catch(Exception f)
          System.out.println(f);
finally
          try
          fos.close();// file output stream closed
          catch(Exception f)
          System.out.println(f);
          try
          dis.close();// input stream to client closed
          catch(Exception f)
          System.out.println(f);
          try
          sos.close();// output stream to client closed
          catch(Exception f)
          System.out.println(f);
}//END OF DOPOST METHOD
} //END OF CLASS
Jocelyn the above code may have tid bit errors which u could understand.But I hope u get the overall idea of whats going on

Similar Messages

  • HELP! File Upload Servlet and Internet Explorer

    Hello people. I hope this is an easy problem to solve...
    I have a servlet upload program that works using Mozilla browser (www.mozilla.org), but for some reason it doesn't work using Microsoft IE. The servlet is also using the servlet upload API from Apache (commons).
    I'm using IE version 6.0.2800.1106 in a Win98SE host computer. I get a cannot find path specified error message (see below). At work, I also get the same error message using IE, but don't know what version. The OS is XP. Unfortunately, at work, I can't install Mozilla browser (or any software-company policy) to see if Mozilla works there too. I would've like to have tested to see if the upload program worked on Mozilla on a truly remote computer.
    So I figured, it must be a IE configuration issue, but darn it!! I began by resetting IE to default settings, but still have the problem, I played around with several different combinations of settings in "Tools"-->"Internet Options...", and I still get the error message. Someone PLEASE HELP ME!!!
    Dunno, if it will help, I've also pasted the upload servlet source code below and the html file that's calling the upload servlet, but you still need the Apache commons file upload API.
    Trust me on this one folks, for some reason it works for Mozilla, but not for IE. With IE, I can at least access web server, and therefore, the html file that calls the upload servlet , so I don't think it's a Tomcat configuration issue (version 5.0). I actually got the code for the file upload servlet from a book relatively new in the market (printed in 2003), and it didn't mention any limitations as far as what browser to use or any browser configuration requirements. I have e-mailed the authors, but they probably get a ton of e-mails...
    Anyone suggestions?
    Meanwhile, I will try to install other free browsers and see if the file upload program works for them too.
    ERROR MESSAGE:
    "HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: C:\TOMCAT\webapps\MyWebApps\files\C:\WINDOWS\Desktop\myfile.zip (The system cannot find the path specified)
         com.jspbook.FileUploadCommons.doPost(FileUploadCommons.java:43)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause
    java.io.FileNotFoundException: C:\TOMCAT\webapps\MyWebApp\files\C:\WINDOWS\Desktop\myfile.zip (The system cannot find the path specified)
         java.io.FileOutputStream.open(Native Method)
         java.io.FileOutputStream.(FileOutputStream.java:176)
         java.io.FileOutputStream.(FileOutputStream.java:131)
         org.apache.commons.fileupload.DefaultFileItem.write(DefaultFileItem.java:392)
         com.jspbook.FileUploadCommons.doPost(FileUploadCommons.java:36)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    note The full stack trace of the root cause is available in the Tomcat logs.
    Apache Tomcat 5.0.16"
    FILE UPLOAD SERVLET source code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.commons.fileupload.*;
    import java.util.*;
    public class FileUploadCommons extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.print("File upload success. <a href=\"/MyWebApp/files/");
    out.print("\">Click here to browse through all uploaded ");
    out.println("files.</a><br>");
    ServletContext sc = getServletContext();
    String path = sc.getRealPath("/files");
    org.apache.commons.fileupload.DiskFileUpload fu = new
    org.apache.commons.fileupload.DiskFileUpload();
    fu.setSizeMax(-1);
    fu.setRepositoryPath(path);
    try {
    List l = fu.parseRequest(request);
    Iterator i = l.iterator();
    while (i.hasNext()) {
    FileItem fi = (FileItem)i.next();
    fi.write(new File(path, fi.getName()));
    catch (Exception e) {
    throw new ServletException(e);
    out.println("</html>");
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    doPost(request, response);
    HTML PAGE that calls the upload servlet:
    <html>
    <head>
    <title>Example HTML Form</title>
    </head>
    <body>
    <p>Select a file to upload or browse
    currently uploaded files.</p>
    <form action="http://##.##.##.####/MyWebApp/FileUploadCommons"
    method="post" enctype="multipart/form-data">
    File: <input type="file" name="file"><br>
    <input value="Upload File" type="submit">
    </form>
    </body>
    </html>
    Thanks in advance for any assistance.
    -Dan

    I'm guessing what is happening is that Mozilla tells the servlet "here comes the file myfile.zip". The servlet builds a file name for it:
        String path = sc.getRealPath("/files");
        // path is now C:\TOMCAT\webapps\MyWebApps\files\
        fi.write(new File(path, fi.getName()));
        // append myfile.zip to "path", making it C:\TOMCAT\webapps\MyWebApps\files\myfile.zipIE, however, tells "here comes the file C:\WINDOWS\Desktop\myfile.zip". Now imagine what the path+filename ends up being...
    So what you want to do is something along the lines of (assuming Windoze):
    public static String basename(String filename)
        int slash = filename.lastIndexOf("\\");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        // I think Windows doesn't like /'s either
        int slash = filename.lastIndexOf("/");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        // In case the name is C:foo.txt
        int slash = filename.lastIndexOf(":");
        if (slash != -1)
            filename = filename.substring(slash + 1);
        return filename;
        fi.write(new File(path, basename(fi.getName()));
        ....You can make the file name check more bomb proof if security is an issue. Long file names trying to overflow something in the OS, NUL characters, Unicode, forbidden names in Windos (con, nul, ...), missing file name, ...

  • ALBPM 6.0 : The maximum size for file uploads has been exceeded.

    Hi,
    I use AquaLogic BPM Entreprise server to deploy my Process. When I try to publish a process on my server I get the following error:
    An unexpected error ocurred.
    The error's technical description is:
    "javax.servlet.jsp.JspException: null"
    Possible causes are:
    The maximum size for file uploads has been exceeded.
    If you are trying to publish an exported project you should publish it using the remote project option.
    If you are trying to upload the participant's photo you should choose a smaller one.
    An internal error has ocurred, please contact support attaching this page's source code.
    Has someone resolve it?
    Thank's.

    Hi,
    Sure you've figured this out by now, but when you get the "Maximum size for file uploads" error during publish consider:
    1. if your export project file is over 10mb, use "Remote Project" (instead of "Exported Project") as the publication source. That way when you select the remote project, you will point to ".fpr" directory of the project you are trying to publish.
    Most times your project is not on a network drive that the server has access to. If this is the case, upload the .exp file to the machine where the Process Administrator is running, then expand it in any directory (just unzip the file). Then, from the Process Administrator, use the option to publish a Remote Project by entering the path to the .fpr directory you just created when unzipping the project.
    2. Check to see if you have cataloged any jars and marked them as non-versionable. Most of the times the project size is big just because of the external jar files. So as a best practice, when you do a project export select the option "include only-versionable jars", that will get reduce the project size considerably (usually to Kb's). Of course you have to manually copy the Jar files to your Ext folder.
    hth,
    Dan

  • BI IP --- Planning function for File Upload

    Hai All,
    In BI IP , When I am trying to load the data (text file) by using Planning function for File Upload. I am getting an error message When I am clicking on Update .
    Error Message : Inconsistent input parameter (parameter: <unknown>, value <unknown>).
    In Text file I am using Tab Separation for each value
    Anyone help me out.
    Thanks,
    Bhima

    Hi Bhima
    Try one of these; it should work:
    1. If you are on SP 14 you would need to upgrade to SP 15. It would work fine
    2. If not, then -
         a] apply note 1070655 - Termination msg CL_RSPLFR_CONTROLLER =>GET_READ_WRITE_PROVIDS
         b] Apply Correction Instruction 566059 [i.e: in Object - CL_RSPLFR_CONTROLLER GET_READ_WRITE_PROVIDS,
    delete the block: l_r_alvl = cl_rspls_alvl=>factory( i_aggrlevel = p_infoprov ).
    and insert block - l_r_alvl = cl_rspls_alvl=>factory( i_aggrlevel = i_infoprov ).
    Goodluck
    Srikanth

  • URGENT! File Upload Utility or a Custom UI for File Upload is needed!

    Hi all,
    I'm trying to find or develop a file upload utility or custom user interface rather than editing and adding file type item to a page. There is a free portlet for file upload in Knowledge Exchange resources, but it is for 3.0.9 release. I'm using portal 9.0.2.
    I could not any sample about the new release. Also API such as wwsbr_api that is used to add item to content areas is out dated.
    I create a page with a region for "items". When "edit" page and try to add an "file" type item the generated url is sth like this;
    "http://host:7779/pls/portal/PORTAL.wwv_additem.selectitemtype****"
    After selecting item type as a simple file autogenerated url is sth. like ;
    "http://host:7779/pls/portal/PORTAL.wwv_add_wizard.edititem"
    I made search about these API but could not find anything (in PDK PL/SQL API help, too).
    I need this very urgent for a proof of consept study for a customer.
    Thanks in advance,
    Kind Regards,
    Yeliz Ucer
    Oracle Sales Consultant

    Answered your post on the General forum.
    Regards,
    Jerry
    PortalPM

  • Good tutorial for using the orielly file upload servlet

    Hello all,
    I just downloaded the packages from the orielly site and I am interested in using the upload servlet. I have the oreilly servlet book but it doesnt get into much detail about how to use the servlet. I have not used servlets before so I need basic advice or a tutorial on using the MultipartRequest servlet. Where can I find this? I checked servlets.com's FAQ but it doesnt have much about how to set it up.
    TIA!

    Thanks but I want to try to use the orielly servlet class I need some practice using servlets as I am relying on jsp's too much.
    Anybody have any pointers on the orielly upload servlet and how to use it.

  • Creating Progress Bar for File Upload

    Hi, I'm trying to implement a progress bar indicator for a file upload in WebDynpro, without very good results.
    I'm using a fileupload UI element, a TimerTrigger and a ProgressIndicator UI elements for this purpose.
    It seems that using the fileupload UI element the iview is locked during the file upload, and therefore it prevents for the timer triggered action to be performed (this action updates the progress bar).
    Additionally I havent been able to capture the transfered bytes from the upload. Maybe I'm using the wrong elements?
    How could I achieve this. Has anyone done it?
    I would really appreciate all the help I could get.
    Homer Vargas

    Hi,
    Can anyone please tell me the way to upload file from client system to server.
    The code i have is as follows:-
    Jsp:-
    function saveImage(){
         //projectname.javafilename
         var strStatus = "save";
         document.saveImageForm.action="/irj/servlet/prt/portal/prtroot/TestXML.TextImageLink?frmstatus="+ strStatus;
         document.saveImageForm.method="post";
         document.saveImageForm.submit();     
    <form name="saveImageForm" encrypt="multipart/form-data">
    <table width="388" cellpadding="1" cellspacing="1" bgcolor="#F0F0F0" border='0'>
           <tr>
                 <td><font color="blue" face="verdana" size="2">IMAGE:</font></td><td><input id="image" type="file" name="image" value=""/></td>
         </tr>
    <tr>
         <td><input type="submit" name="submit" value="Submit" onclick="saveImage();"/></td>
         </tr>
    </table>
    </form>
    now i am not getting what to write in java file
    using IPortalComponentRequest.
    Using the jsp file upload in tomcat is working but here it is not working
    please help meee
    Thanks in Advance
    Regards
    Sirisha

  • Difficulties in creating a JSP for File upload

    hello out there,
    im trying to create a ProcessUpload.jsp File which should handle a file upload from a channel in the portal. regarding a previously posted thread acording to fileupload i deployed this jsp-file in the regular webServerHierarchy so that you dont have to go into the desktopServlet Portal, which cant handle fileUpload.
    its location is this ../portal/test/ProcessUpload.jsp and it uses CustomTags referecens from /portal/WEB-INF/test.tld. i customized the deployment descriptor in /portal/WEB-INF/web.xml as well. but as soon as i try to put a taglib which uses this custom tags the server responses with an error.
    does anybody know how to deploy a global jsp file to handle file uploads, or something in particular how to deploy jsp with custom tags outside the desktopservlet but inside the portal webapp??
    i would be really thankful ;-)
    best regards
    martin

    hi alex,
    i allready tried to realize a channel with file upload download. channels are made up of jsp pages and when i am forwarding my form with enctype="multipart/form-data" encoding the desktop-servlet intercpets my entity-body.
    so what kind of channel you have thought about ??
    thanks for reply ;-)

  • Error handling for file upload

    HI Experts,
    I have a question on file upload process in sap MDG-S.
    Scenario : Upload the content from a CSV file using the file upload prcoess.
    Query : For example if there are 5 records in the file and if there is an error in 3rd record what happens to the rest of the records i.e. 1,2 and 3,4.
    a) Will record 1 and record 2 get posted and record 3,4 will be failed?
    b) All 4 records will not be posted as there is one errored record.
    Regards,
    Charita.

    Hi charitha,
    As per your request if there is a error in any of the record in a particular file it does'nt loads any of the fields to the target, it will be terminated  with an error.
    As i checked with an example of Space delimited file in which 4th field has no spaces, and i used this file as source and run the job it does'nt return any values but terminated with an error.
    let me know if i am right..
    Regards,
    Amjad

  • Emulating HTTP POST for file upload with J2ME

    I have search through a lot of site and couldn't find the actual code. I try to emulate below html with J2ME.
    <form method="POST" enctype="multipart/form-data" action="Insert.asp">
    <td>File :</td><td>
    <input type="file" name="file" size="40"></td></tr>
    <td> </td><td>
    <input type="submit" value="Submit"></td></tr>
    </form>
    here is my code :
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    byte[] filecontent = file byte content ...
    try {
    c = (HttpConnection)Connector.open("http://xx.com/insert.asp");
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("Content-Length", String.valueOf(cmg.length + 15));
    c.setRequestProperty("Content-type","multipart/form-data");
    os = c.openOutputStream();
    os.write("file=c:\\abc.png".getBytes());
    os.write(filecontent);
    os.flush();
    I can emulate form with text field and it work, but when it come to file upload, above code not working, I don't know what to put for the outputstream, filename ? content ? or both ? since the html only has one field that is the "file" field. The file is actually store in rms with filename abc.png, and I just put in the c:\ for the server as a dump path.

    File upload is more complicated then that... you need multi-part MIME formatting.... But I have just the code...
    http://forum.java.sun.com/thread.jspa?forumID=256&threadID=451245

  • Validator for file upload component is not working !!

    This validator method for a file upload component is throwing a java.lang.NullPointerException.
    public void fileUpload1_validate(FacesContext context, UIComponent component, Object value) {
    long size= fileUpload1.getUploadedFile().getSize();
    if (size>65535){
    throw new ValidatorException(new FacesMessage("Your image is too big!"));
    Any help to solve this problem is very much appreciated.
    Thanks.

    Hi i have a fileUpload in a pop-up and the methods are :
    public void fileUpload1_validate(FacesContext context, UIComponent component, Object value) {
    try {
    com.sun.rave.web.ui.model.UploadedFile uploadedFile = ((Upload)component).getUploadedFile();
    long l_filesize = uploadedFile.getSize();
    if ( l_filesize > 1000000)
    throw new ValidatorException(new FacesMessage("File Size should be less than 1000000 bytes! It is" + l_filesize));
    else {
    String tipo = uploadedFile.getContentType();
    if ( tipo.compareTo("application/word") == -1 )
    if ( tipo.compareTo("application/rtf") == -1 )
    if ( tipo.compareTo("application/pdf") == -1 )
    throw new ValidatorException(new FacesMessage("Error : los tipos de archivo aceptados son PDF, WORD y RTF"));
    } catch (Exception ex) {
    this.mauvaisFichier = true;
    error(ex.getMessage());
    public String botonValidar_action() {
    if ( !this.mauvaisFichier )
    if ( this.fileUpload1.getUploadedFile() != null )
    if ( this.fileUpload1.getUploadedFile().getSize() > 0 )
    try {
    this.getSessionBean1().getComunicacion().setArchivo( new javax.sql.rowset.serial.SerialBlob(this.fileUpload1.getUploadedFile().getBytes() ) );
    this.getSessionBean1().getComunicacion().setTipoArchivo( this.fileUpload1.getUploadedFile().getOriginalName().substring(this.fileUpload1.getUploadedFile().getOriginalName().length() - 3 ) );
    } catch(Exception e){
    e.getMessage();
    return null;
    I have to put a boolean value because the first time, validation code doesn't function ( the method botonValidar_action() is called ) correctly. The error message appears but empty.
    If I try next time then it's ok.
    Thx for any issue.

  • Size limit for files uploaded to htmldb_application_files

    Hi,
    Is there any size limit for files which are to be uploaded to htmldb_application_files (and then stored as BLOB in db)?
    Regards,
    Tom

    Hi Tom,
    the only limitation is that the BLOB data type is 4GB
    large.
    So you can store max. 4 GB data in BLOB.Did you mean BFILE? Depending on the version, size limit is between 8TB and 128TB, as in the 10g2 documentation:
    PL/SQL LOB Types
    C.

  • Need help for file upload - reposted for Steve Muench

    Hi Steve,
    I have been involved developing a web application that requires a file upload operation. I have studied your example on Upload Text File and Image Example in the Not Yet Documented ADF Sample Applications section. I got the file upload part worked but could not get the original file name to populate the name field..i.e. if I upload myFile.txt to the database, the name field will be myFile.txt (not the name enter by user). Is there a way to capture the filename info? or is it possible to do so within ADF framework? I am using ADF/Struts/JSP with ORDDoc data type. Thanks very much.
    Bill

    Hello Nani,
    You need to change any settings in 'FILE' transaction. This transaction is used to set up Logical file paths. ( In general it will be set already for your system).
    You can use the following code.
      DATA: LC_LOGICAL_FILENAME_EXPSRC LIKE RCGIEDIAL-IEFILE
                                                    VALUE 'EHS_IMP_SOURCES'.
      DATA:      L_EMERGENCY_FLAG            TYPE C.
      DATA:      L_FILE_FORMAT               LIKE FILENAME-FILEFORMAT.
      data : X_RCGIEDIAL LIKE  RCGIEDIAL occurs 0 with HEADER LINE.
      read the default pathname on application server
        CALL FUNCTION 'FILE_GET_NAME'
             EXPORTING
                CLIENT                  = SY-MANDT
                  LOGICAL_FILENAME        = LC_LOGICAL_FILENAME_EXPSRC
                  OPERATING_SYSTEM        = SY-OPSYS
                parameter_1             = ' '
                PARAMETER_2             = ' '
                USE_PRESENTATION_SERVER = ' '
                WITH_FILE_EXTENSION     = ' '
                USE_BUFFER              = ' '
             IMPORTING
                  EMERGENCY_FLAG          = L_EMERGENCY_FLAG
                  FILE_FORMAT             = L_FILE_FORMAT
                  FILE_NAME               = X_RCGIEDIAL-IEFILE
             EXCEPTIONS
                  FILE_NOT_FOUND          = 1
                  OTHERS                  = 2.
        write :/ 'file format', L_FILE_FORMAT,
               / 'file name', X_RCGIEDIAL-IEFILE.
    Thanks,
    Jyothi

  • No of Columns limitation for file upload APEX 4.1

    Hi,
    I am using apex 4.1 file upload wizard to upload csv data.My csv file contains 58 columns that i have to insert into table.
    when i proceed with the wizard and inserted records into the table. only first 46 records has been inserted.
    Also, data\table mapping form also shows only 46 columns for column mapping.
    Is there any column limit to file upload?
    Can you help me on the same?

    Hi Frank,
    Yes you are right, the number of columns (through data upload feature) is limited to 46 columns.
    Regards,
    Patrick

  • Using Resource type in Netweaver 7.1 for file upload

    Dear All,
    I want to check the file extension and file size before uploading it through a file upload UI element in Web Dynpro 7.1.
    How to go about it? And I am using following code for image upload. Is it correct one?
    IWDResource photoData = wdContext.nodePhotos().getPhotosElementAt(i).getPhotoData();
    FtpURLConnection myConnection = new FtpURLConnection(myUrl);          
    myConnection.connect();                    
    OutputStream out = myConnection.getOutputStream();               
    int temp = 0;
    InputStream text = photoData.read(false);
    while((temp=text.read())!=-1)
            out.write(temp);
    out.flush();
    out.close();
    myConnection.close();               
    Kindly help.
    Regards,
    Amey Mogare

    Did you check [this|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71] one?
    Bala

Maybe you are looking for