File upload in Linux Platform

Hi,
I have a web application with file upload , which is working fine in my local machine(Windows platform). But when I deploy the .war file in Linux based system, the file upload option is not working. I have used the following in my jsp
page.
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>

I have given all (rwx) the permissions to the folder
to which i am uploading the files.it's having a problem with the TEMP dir.

Similar Messages

  • File getName on Linux platform

    Hello, I am trying to utilize the Jakarta commons upload component. When I try to run the following locally, it works:
    while(i.hasNext()) {
         FileItem item = (FileItem)i.next();
         File fullFile  = new File(item.getName());
         logger.info("Name is " + item.getName());
         File savedFile = new File(getServletContext().getRealPath("/"), fullFile.getName());
         logger.info("SavedFile is " + savedFile.toString());
         item.write(savedFile);
    }However, when I deploy this to a Linux server, it doesn't work properly since the fullFile.getName() line is returning the full path and not just extracting the file name. I read that is because Linux allows the '\' and such in filenames. Is there a way around this?

    Not sure if you got an answer but I just ran into this issue too. The issue is that the \ character is valid in a file name on Linux.
    What I ended up doing is translating the \ character to / in the path. To get the name then you have to create a File object with the translated name then us the getName() method.
    while(i.hasNext()) {
         FileItem item = (FileItem)i.next();
         File fullFile = new File(item.getName());
         logger.info("Name is " + item.getName());
    // I added these three lines and changed the object in the savedFile instantiation to tempFile
    String tempName = fullFile.getName();
    tempName = tempName.replace('\\','/');
    FIle tempFile = new File(tempName);
         File savedFile = new File(getServletContext().getRealPath("/"), tempFile.getName());
         logger.info("SavedFile is " + savedFile.toString());
         item.write(savedFile);
    }

  • File Upload Problem from Linux to Windows and Windows to Linux

    Hi,
    I am a newbie in the flex environment.
    I have faced a problem for file upload from linux to windows and windows to linux
    And I have put crossdomain.xml file in root folder, still this problem is appear.
    Please help me, if anybody know the answer.
    Thanks and Regards,
    Senthil KUmar

    Hi Pauley,
    I thought you are moving from unix to windows. Now I got it.
    Make sure that the folder is shared and have necessary permissions. Please see few suggestions here:
    Re: NFS or FTP for file on Ip 10.x.y.z
    Regards,
    ---Satish

  • 11.3 File Upload Extension

    Since upgrading to 11.3 we're unable to install the file upload extension for firefox (ESR 24.5) on OS X (tried 10.8 and 10.9 - the extension works fine in win7). The link "Install the Novell File Upload extension to upload directories" is there but clicking doesn't do anything. It was working under 11.2.4, but hasn't worked since we upgraded to 11.3. Has anyone else run into this and found a solution?

    On 30/05/2014 13:41, Shaun Pond wrote:
    > the file upload extension never was supported on Macs - are you sure it
    > used to work?
    Whilst I think you're correct the documentation needs updating since it
    currently implies that whilst IE is supported on Windows (well duh!) and
    Firefox 26.0 and 27.0 on Windows and Linux, Firefox ESR 17.0 and 24.0
    are supported on all platforms due to absence of Windows and/or Linux
    qualifiers.
    From
    https://www.novell.com/documentation...uirements.html
    --begin--
    The following web browsers are supported:
    * Internet Explorer 8 (32-bit only) on Windows Vista, Windows 7, Windows
    Server 2003, Windows XP, Windows Server 2008, and Windows Server 2008 R2
    * Internet Explorer 9 (32-bit only) on Windows Vista, Windows 7, Windows
    Server 2003, Windows XP, Windows Server 2008, and Windows Server 2008 R2
    * Internet Explorer 10 (32-bit only) on Windows Vista, Windows 7,
    Windows Server 2003, Windows XP, Windows Server 2008, Windows Server
    2008 R2, Windows 8, and Windows Server 2012
    IMPORTANT:
    * Internet Explorer versions prior to version 8 are not supported.
    * Internet Explorer 11 is not supported; there are a few known issues
    related to the support of this version of Internet Explorer in ZENworks.
    * Firefox ESR version 17.0 and 24.0
    * Firefox version 26.0 and 27.0 (including any patches) on Windows and
    Linux devices
    ---end---
    I'll report it (along with missing CSS formatting and some broken links
    I just found).
    HTH.
    Simon
    Novell Knowledge Partner
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below. Thanks.

  • JSP Uploader on Linux Issue

    Hi.
    I have a JSP uploader. This works fine on Windows platforms. The linux version works well too, but only with text files. Any other file (.gpeg, .odt, .pdf etc) get corrupted in some way or another on uploading.
    Kindly look at the code involved and help me out. Thanks.
    <%@ page import="java.io.*, java.lang.*" %>
    <%
    out.println("Uploading your file. Please wait...");%><br><%
    String operatingSystemVersion = String.valueOf(System.getProperty("os.name"));
    FileOutputStream fileOut = null;
    if(operatingSystemVersion.startsWith("Linux"))
         String contentType = request.getContentType();
         String file = null;
         String saveFile = "";
         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;
                   out.print("Boundary: " + boundaryLocation + "   ");
                   int startPos = ((file.substring(0, pos)).getBytes()).length;
                   out.print("startPos: " + startPos + "   ");
                   int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
                   out.print("endPos: " + endPos + "   ");
                   //Specify the folder here that you want the file uploaded into
                   // Note that you need read/write permissions to that folder
                   String folder = "/home/arthur/uploads/";
                   fileOut = new FileOutputStream(folder + saveFile);
                   for(int i = 0; i < dataBytes.length; i++)
                        byte data = dataBytes;
                        fileOut.write(data);
                   fileOut.write(dataBytes, startPos, (endPos - startPos));
    //               out.print("Writing out OK");
                   out.print("flushing...");
                   fileOut.flush();
                   //     here </TD>
                   //     <meta HTTP-EQUIV="Refresh" content="5; URL=index.jsp">
                   //     <br>
              catch(Exception e)
                   out.print(e);
    else
         String saveFile = "";
         String contentType = request.getContentType();
         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
                   String 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=\"");
                   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;
                   // Specify the folder here that you want the file uploaded into
                   // Note that you need read/write permissions to that folder
                   String folder = "C:/Program Files/Apache Software Foundation/Tomcat5.5/webapps/upload/images/";
                   fileOut = new FileOutputStream(folder + saveFile);
                   fileOut.write(dataBytes, startPos, (endPos - startPos));
                   fileOut.flush();
                   fileOut.close();
                   %>
                        <meta HTTP-EQUIV="Refresh" content="5; URL=index.jsp">
                   <%
              catch(Exception e)
                   out.print(e);
              finally
                   try{fileOut.close();}catch(Exception err){}
    %>
    {code}

    I have acquired Apache file upload and modified upload.jsp and this is how it looks:
    <%@ page import="java.io.*, java.lang.*, org.apache.commons.io.*, org.apache.commons.fileupload.*" %>
    <%
              out.println("Uploading your file. Please wait...");%><br><%
              DiskFileItemFactory factory = new DiskFileItemFactory();
            // maximum size that will be stored in memory
            factory.setSizeThreshold(4096);
            // the location for saving data that is larger than getSizeThreshold()
            factory.setRepository(new File("C:/tmp"));
            ServletFileUpload upload = new ServletFileUpload(factory);
            // maximum size before a FileUploadException will be thrown
            upload.setSizeMax(1000000);
            List fileItems = upload.parseRequest(req);
            // assume we know there are two files. The first file is a small
            // text file, the second is unknown and is written to a file on
            // the server
            Iterator i = fileItems.iterator();
            String comment = ((FileItem)i.next()).getString();
            FileItem fi = (FileItem)i.next();
            // filename on the client
            String fileName = fi.getName();
            // save comment and filename to database
            // write the file
            fi.write(new File("C:/", fileName));
    %>However, Tomcat complains that
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 4 in the jsp file: /upload.jsp
    DiskFileItemFactory cannot be resolved to a type
    1: <%@ page import="java.io.*, java.lang.*, org.apache.commons.io.*, org.apache.commons.fileupload.*" %>
    2: <%
    3: out.println("Uploading your file. Please wait...");%><br><%
    4: DiskFileItemFactory factory = new DiskFileItemFactory();
    5:
    6: // Set factory constraints
    7: factory.setSizeThreshold(yourMaxMemorySize);
    An error occurred at line: 4 in the jsp file: /upload.jsp
    DiskFileItemFactory cannot be resolved to a type
    1: <%@ page import="java.io.*, java.lang.*, org.apache.commons.io.*, org.apache.commons.fileupload.*" %>
    2: <%
    3: out.println("Uploading your file. Please wait...");%><br><%
    4: DiskFileItemFactory factory = new DiskFileItemFactory();
    5:
    6: // Set factory constraints
    7: factory.setSizeThreshold(yourMaxMemorySize);
    An error occurred at line: 7 in the jsp file: /upload.jsp
    yourMaxMemorySize cannot be resolved
    4: DiskFileItemFactory factory = new DiskFileItemFactory();
    5:
    6: // Set factory constraints
    7: factory.setSizeThreshold(yourMaxMemorySize);
    8: factory.setRepository(new File("C:/Documents and Settings/Arthur/Desktop/"));
    9:
    10: // Create a new file upload handler
    An error occurred at line: 11 in the jsp file: /upload.jsp
    ServletFileUpload cannot be resolved to a type
    8: factory.setRepository(new File("C:/Documents and Settings/Arthur/Desktop/"));
    9:
    10: // Create a new file upload handler
    11: ServletFileUpload upload = new ServletFileUpload(factory);
    12:
    13: // Set overall request size constraint
    14: upload.setSizeMax(yourMaxRequestSize);
    An error occurred at line: 11 in the jsp file: /upload.jsp
    ServletFileUpload cannot be resolved to a type
    8: factory.setRepository(new File("C:/Documents and Settings/Arthur/Desktop/"));
    9:
    10: // Create a new file upload handler
    11: ServletFileUpload upload = new ServletFileUpload(factory);
    12:
    13: // Set overall request size constraint
    14: upload.setSizeMax(yourMaxRequestSize);
    An error occurred at line: 14 in the jsp file: /upload.jsp
    yourMaxRequestSize cannot be resolved
    11: ServletFileUpload upload = new ServletFileUpload(factory);
    12:
    13: // Set overall request size constraint
    14: upload.setSizeMax(yourMaxRequestSize);
    15:
    16: // Parse the request
    17: List /* FileItem */ items = upload.parseRequest(request);
    An error occurred at line: 17 in the jsp file: /upload.jsp
    List cannot be resolved to a type
    14: upload.setSizeMax(yourMaxRequestSize);
    15:
    16: // Parse the request
    17: List /* FileItem */ items = upload.parseRequest(request);
    18: %>
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
    Apache Tomcat/5.5.23Any help?

  • Error on File upload. Error processing wwv_flow.accept.

    Hi,
    I'm developing an application to upload and download files using Oracle XE 10g and APEX 3.2.0.00.27 on OS Windows XP.
    The file upload page is very simple: one file browse item, a submit button and a report based on the wwv_flow_files table.... and an extra button to save the uploaded files in the DB.
    Sometimes (almost everytime) when I press the submit button, the wwv_flow.accept process fails and I'm redirected to a page saying Internet Explorer cannot display the webpage.
    I'm forced to refresh the page and then I get the following message:
    Expecting p_company or wwv_flow_company cookie to contain security group id of application owner.
    Error ERR-7621 Could not determine workspace for application (:) on application accept.
    I recreated the same page in the apex.oracle.com environment and it works, but it fails in my local environment.
    I have read some posts int his forum, but I haven't found an answer yet.
    Please help!!!
    AUJ

    varad acharya wrote:
    Download the standalone OHS.
    http://www.oracle.com/technology/software/products/database/oracle11g/111060_win32soft.html
    varadSorry about this...old post and off topic.
    Can anyone point me to a standalone version of OHS for linux x86-64? I'm having troubles finding this, it doesn't appear to have installed with 11g Enterprise Edition and I cannot find it in the available packages when I re-run the installer. I'm running 11g EPG now and want to convert to Apache.
    Thanks!!!

  • Running a perl shell command through a java program on linux platform

    i'm trying to execute the following command in a java program "perl xxx.pl" using the runtime.getruntime method
    here is the piece of code
    String[] cmd={"perl","-c","AraMorph.pl",""};
    Process p = Runtime.getRuntime().exec(cmd,null,new File("/home/ahmed/buckwalter_morphan_1/data"));
    p.waitFor();
    BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line=in.readLine())!=null)
    System.out.println(line);
    but it doesn't output anything even if i tried to print the output to a file
    i'm trying to execute this program on linux platform but its working properly on a windows platform
    thx
    raar

    String[] cmd={"perl","AraMorph.pl"," </home/ahmed/in.txt"," >/home/ahmed/ast.txt"};
    Process p = Runtime.getRuntime().exec(cmd,null,new File("/home/ahmed/buckwalter_morphan_1/data"));
    BufferedReader in=new BufferedReader(new InputStreamReader(p.getErrorStream()));
    String line;
    while ((line=in.readLine())!=null)
    System.out.println(line);
    p.waitFor();
    String str2=p.getInputStream().toString();
    System.out.println("==================================="+str2);
    and it still outputs nothing but goes in something like infinite loop or as assumed in the article u suggested a deadlock but even all solutions to all pitfalls didn't succeed

  • File Upload problem: JSF, IBM WPS and Portlet - Please HELP Vey Very Urgent

    I want to upload a file from the front end using JSF and Portlets deployed on IBM WebSphere Portal.
    I have used Apache's commons file upload functionality as the file upload provided in JSF doesnot work with portlets and the action event is not invoked If I keep enctype="multipart/form-data". So I included 3 forms in my Faces JSP file.
    1) h:form = For displyign error message on screen
    2) html:form = Include the enctype="multipart/form-data" and the input type file for uploading. And a submit button
    3) h:form: Here I have a command link which is remotely excuted on click of sumit button in my html form. This is to invoke the action event in the pagecode to get the bean value from the context.
    Now in the my doView method in the portlet, isMultipartContent(httpservletrequest) always returns null as the content type is text/html and not multipart. Onclick of the submit button in the the html form I am calling a javascript function which sets the __LINK_TARGET__ to the command link in the 3rd h:form which will call the page code.
    The problem here is action is invoked only when I return false from the above javascript else it will trigger for the first time and from second time onwards it will not invoke the action event in the pagecode method. Whent the javascript function returns false, the content type is always text/html. However if I return "true" from the javascript the content type is multipart/form-data, but the action is not triggered for the second time. So basically when the javascript functions returns true, for the first click everything works perfectly. When it returns false, the content type is text/html, but the action is invoked in the page code every time.
    Returning always true would solve my problem with the content type, but the action with the command link will not get invoked always as its some type of problem with h:commanLink :(.
    I guess I gave too much info. Heres my code stepby step.
    Can somebody please tell me , how I should also invoke the action in the page code and get the content type as "multipart/form-data" at the same time.
    1:
    ======================= Faces JSP File: BPSMacro.jsp ====================
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="GENERATOR" content="IBM Software Development Platform">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="/WEB-INF/tld/j4j.tld" prefix="j4j"%>
    <%@taglib uri="/WEB-INF/tld/core.tld" prefix="core"%>
    <%@page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1" session="false"%>
    <portlet:defineObjects />
    <link rel="stylesheet" type="text/css"
         href='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/theme/stylesheet.css") %>'
         title="Style">
    <script type="text/javascript">
    function formSubmit() {
         var formName2 = document.getElementById("proxy_form_main_").title;
         var formName1 = document.getElementById("BPSMacroFormId").title;
         document.getElementById("__LINK_TARGET__").value = document.getElementById("proxy_HD_COMMAND_").title;
         document.getElementById(formName2).submit();
         return false;
    </script>
    <f:view>
         <hx:scriptCollector id="bpsMacroScriptCollector">
              <f:loadBundle var="bps" basename="bordereauprocessingsystem" />
              <table bgcolor="#FFF9C3">
                   <tr>
                        <td><h:form id="BPSMacroFormMain" styleClass="form">
                             <table class="tablemiddle" cellspacing="0" cellpadding="0">
                                  <tr>
                                       <td><h:messages layout="table" styleClass="errormessage"
                                                 id="ValidationErrorMsg" /> </td>
                                  </tr>
                             </table>
                             <j4j:idProxy id="proxy_form_main_0_" />
                        </h:form></td>
                   </tr>
                   <tr>
                        <td>
                        <form id="BPSMacroFormId" enctype="multipart/form-data">
                        <table bgcolor="#FFF9C3">
                             <tr>
                                  <td height="36" width="324">Worksheet <input type="file"
                                       name="upfile" /></td>
                             </tr>
                                  <tr>
                                       <td align="center" width="324"><input TYPE="submit"
                                       onclick="return formSubmit();" value="Upload">
                                  </td>
                             </tr>
                        </table>
                        </form>
                        </td>
                   </tr>
                   <tr>
                        <td>
                        <h:form id="BPSMacroFormMain2" styleClass="form">
                             <table cellspacing="2" cellpadding="2" class="tablemiddle">
                                  <tbody>
                                       <tr>
                                            <td colspan="2" align="center"><h:commandLink
                                                 styleClass="commandLink" id="lnkuserdelete"
                                                 action="#{pc_BPSMacro.doIdUpload1Action}">
                                                 <hx:graphicImageEx
                                                      styleClass="graphicImageEx" id="imgBtnCreateUser"
                                                      value="/theme/images/btnUpload.gif" style="border:0;cursor:pointer"></hx:graphicImageEx>
                                                 <j4j:idProxy id="proxy_HD_COMMAND_" />
                                            </h:commandLink></td>
                                            <h:inputHidden id="dtSize"
                                                 value="#{pc_BPSMacro.fileDetailsList.clicked}">
                                                 <j4j:idProxy id="proxy_clicked_" />
                                            </h:inputHidden>
                                       </tr>
                                  </tbody>
                             </table>
                             <j4j:idProxy id="proxy_form_main_" />
                        </h:form>
                   </td>
                   </tr>
              </table>
         </hx:scriptCollector>
    </f:view>
    ================== END: FACES JSP FILE: BPSMacro.jsp ========================
    2:
    =================== Action event in the Page Code: BPSMacro.java ============
    public String doIdUpload1Action() {
              System.out.println("PageCode");
              FacesContext context = FacesContext.getCurrentInstance();
              BPSMacroDetailsDataBean fileDetails = (BPSMacroDetailsDataBean)context.getApplication().createValueBinding("#{fileDetails}").getValue(context);
              BPSMacroListDataBean fileDetailsList = (BPSMacroListDataBean)context.getApplication().createValueBinding("#{fileDetailsList}").getValue(context);
              PortletSession sess = (PortletSession)context.getExternalContext().getSession(false);
              sess.setAttribute("BPS_MACRO_CONTEXT", context, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_DETAILS", fileDetails, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_LIST", fileDetailsList, PortletSession.APPLICATION_SCOPE);
              HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
              boolean isMultipart = ServletFileUpload.isMultipartContent(request);
              request.getContentType();
              return "gotoBPSMacro";
    ============== END Of Page Code Action event ==============================
    3:
    ============== doView() Portlet method ================================
    public void doView(RenderRequest arg0, RenderResponse arg1)
         throws PortletException, IOException {
              String METHOD_NAME = "doView(RenderRequest arg0, RenderResponse arg1)";
              Logger.debug(this.getClass(), METHOD_NAME, "Entering BPSMacroPortlet");
              FacesContext context = FacesContext.getCurrentInstance();      
              PortletSession sess1 = arg0.getPortletSession(true);
              BPSMacroDetailsDataBean fileDetails = new BPSMacroDetailsDataBean();
              BPSMacroListDataBean fileDetailsList = new BPSMacroListDataBean();
              context = (FacesContext)sess1.getAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              if(context != null){
                   fileDetails = (BPSMacroDetailsDataBean)sess1.getAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
                   fileDetailsList = (BPSMacroListDataBean)sess1.getAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              HttpServletRequest servletRequest = (HttpServletRequest)arg0;
              PortletRequest pReq = (PortletRequest)arg0;
              HttpServletResponse servletResponse= (HttpServletResponse)arg1;
              System.out.println("\n\n Content Type" + servletRequest.getContentType());
              try{
                   if(context != null){
              boolean isFileMultipart = ServletFileUpload.isMultipartContent(servletRequest);
              System.out.println("\nFILE TO BE UPLOADED IS MULTIPART ? " + isFileMultipart);
              if(isFileMultipart){
                   FileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List items = upload.parseRequest(servletRequest);
                   Iterator iterator = items.iterator();
                   while (iterator.hasNext()) {
                        FileItem item = (FileItem) iterator.next();
                        InputStream iStream = item.getInputStream();
                        ByteArrayOutputStream ByteArrayOS = new ByteArrayOutputStream();
                        int sizeofFile =(int) item.getSize();
                        byte buffer[] = new byte[sizeofFile];
                        int bytesRead = 0;
                        while( (bytesRead = iStream.read(buffer, 0, sizeofFile)) != -1 )
                             ByteArrayOS.write( buffer, 0, bytesRead );
                        String data = new String( ByteArrayOS.toByteArray() );
                        int k = 0;
                        //Check if the file is Refund or Premium
                        int dynamicArraySize = 0;// = st2.countTokens() * 9;
                        dynamicArraySize = st2.countTokens() * 9;
                        if (!item.isFormField() ){
                             File cfile=new File(item.getName());
                             String fileName = "";
                             String separator = "\\";
                             int pos = item.getName().lastIndexOf(separator);
                             int pos2 = item.getName().lastIndexOf(".");
                             if(pos2>-1){
                                  fileName =item.getName().substring(pos+1, pos2);
                             }else{
                                  fileName =item.getName().substring(pos+1);
                             File fileToBeUploaded=new File("C:\\Sal\\BPS MACRO\\FileTransfer\\Desti", fileName);
                             item.write(fileToBeUploaded);
                             validate.displaySuccessMessage(context);
              }catch(Exception e){System.out.println(e);
              Logger.debug(this.getClass(), METHOD_NAME, "Leaving BPSMacroPortlet");
              super.doView(arg0, arg1);
    ==== END: doView method in the portle class. ================================
    Thanks.

    one more question. Is there a way where I can submit two forms ?
    Thats is submit 2nd form only when the first form is submitted.
    I tried this it works.
    function formSubmit(){
    document.form1.submit();
    alert();
    document.form2.submit();
    But If I dont put an alert(basically it disables the parent page) in between, only the second form is submitted.
    If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the code triggered due to first form submit.
    Thus disabling the paresnt page for a few seconds is reolving my problem.
    Any ideas ?
    Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??
    Edited by: hector on Oct 9, 2007 11:09 AM
    Edited by: hector on Oct 9, 2007 2:12 PM

  • Reliable file upload using JDev, AS and other

    Hello,
    I'm not sure this is the right place to post this message, sorry if I was wrong to put it here.
    The question is our company is developing software, for active data exchange with other systems. We decided to exchange in xml format, by means of both web services and web interface (so that exchange could happen both automatically and on user request). We use JDev to develop, Oracle AS to deploy application. Systems we exchange can use various platforms, in fact, it doesn't matter what exactly they use. The question is we need a reliable way to exchange large (sometimes small, but can be 1Gb or, for example, 10Gb) files, maybe with appropriate security, so that it could continue if something happens with network connection.
    One simple decision is to have a web service that accepts, for example, 100K at a time, and another service continuously calls it until file is transfered. So it can check response code. But are there better decisions? I think, there are libraries or smth like this?
    Thanks in advance, believe, it's a right place to get help.
    Valeriy

    Another, simpler (we think), such package is Jenkov HTTP Multipart File Upload. It's a servlet filter which can work in front of both servlets and JSP's. The servlet filter parses the uploaded file and stores it temporarily on the servers disk. When the servlet or JSP executes afterwards, it can obtain all the information about the file, from the request attributes. There is a decent manual for HTTP Multipart File Upload on the website.
    Just search for "Jenkov HTTP Multipart" on Google and you'll find it. HTTP Multipart is free, open source, Apache Licsense.

  • File Upload issues

    There is a file upload that I have and I am getting an
    error...
    Notice: Undefined variable: file_list in
    C:\vhosts\mysite\upload\index.php on line 20
    On line 20 in my php page happens to be the following code
    that is giving an error...$file_list .= "<option value=\"$file\"
    >$file</option>";
    <?php
    #for windows...
    $dirname = $_SERVER['DOCUMENT_ROOT'].'/_assets/professor/';
    //$dirname = "C:\\wamp\\www";
    #(for Linux... $dirname = "user/local/apache/bin";)
    $dir = opendir($dirname);
    while(false != ($file = readdir($dir))){
    if(($file != ".") and ($file != "..")){
    $file_list .= "<option value=\"$file\"
    >$file</option>";
    closedir($dir);
    ?>
    This is what is in the body...
    <form enctype="multipart/form-data" action="uploaded.php"
    method="POST">
    <fieldset><legend>Upload Professor
    Image</legend>
    <!-- MAX_FILE_SIZE must precede the file input field
    -->
    <!--input type="hidden" name="MAX_FILE_SIZE"
    value="30000" /-->
    <!-- Name of input element determines name in $_FILES
    array -->
    Send this file: <input name="userfile" type="file" />
    <div align="center"><input type="submit"
    value="Send File" /></div>
    </fieldset>
    </form>
    <br>
    <br>
    <form action="delete.php" method="post">
    <fieldset><legend>Delete Professor
    Image</legend>
    <select name="deleteFile">
    <?php echo($file_list); ?>
    </select>
    <div align="center"><input type="submit" name="go"
    value="Delete File"></div>
    </fieldset>

    AdonaiEchad wrote:
    > There is a file upload that I have and I am getting an
    error...
    > Notice: Undefined variable: file_list in
    C:\vhosts\mysite\upload\index.php on
    > line 20
    > On line 20 in my php page happens to be the following
    code that is giving an
    > error...$file_list .= "<option value=\"$file\"
    >$file</option>";
    What that's telling you is that you're adding a value to a
    variable that
    doesn't yet exist. In your case, it probably doesn't matter,
    but using
    undefined variables is a potential security risk. To
    eliminate the
    warning - and the risk - declare $file_list before using it:
    $file_list = '';
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • File Uploads using stored procedures

    Hello, I'm quite new here, but I have a question that I've been butting my head against for the past day. Here goes.
    We need to upload a file using a stored procedure (PL/SQL procedure.)
    The two things I have found that work are
    1) Having oracle do the file handling (using bfiles) in the procedure
    2) using an insert statement directly to upload the file contents into a blob.
    The platform is php (Oracle instant client) and I will show some code examples.
    1) is unworkable because Oracle will not have direct access to any files.
    2) is fine, but we would prefer to use a procedure so as to abstract what exactly goes on and possibly other operations away from the php and the framework.
    What worked:
    1)
    CREATE OR REPLACE PROCEDURE php_upload_file (file_name in varchar2, canonical_name in varchar2, owner in number, file_id IN OUT number)
    AS
    src_loc bfile:= bfilename('DOC_LOC',php_upload_file.file_name);
    dest_loc BLOB;
    begin
    insert into files values(owner,canonical_name,empty_blob(),files_seq.nextval) returning files.data, files.file_id
    into dest_loc, file_id;
    dbms_lob.open(src_loc,DBMS_LOB.LOB_READONLY);
    DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.LOADFROMFILE(
    dest_lob => dest_loc
    ,src_lob => src_loc
    ,amount => DBMS_LOB.getLength(src_loc));
    DBMS_LOB.CLOSE(dest_loc);
    DBMS_LOB.CLOSE(src_loc);
    COMMIT;
    end;
    'DOC_LOC' is a directory I've set up that the user has access to.
    Interfacing with PHP this just looks like
    oci_parse($conn,"BEGIN php_upload_file('{$uploadfilename}','{$propername}',{$ownerid},:file_id); END;");
    Dead simple, right?
    I also do a bind command to pull out 'file_id' so I know the id that was just inserted.
    The other solution is
    $contents = file_get_contents($_FILES["uploadedfile"]["tmp_name"]);
    $lob = oci_new_descriptor($conn, OCI_D_LOB);
    $stmt = oci_parse($conn,
    "INSERT INTO files (employee_id, filename, data, file_id) VALUES(175,'"
    .$_FILES["uploadedfile"]["name"].
    "', empty_blob(), files_seq.nextval) RETURNING file_id, files.data INTO :file_id, :src_contents");
    where :src_contents is binded to a lob and :file_id as before is binded to an INT:
    oci_bind_by_name($stmt, ':src_contents', $lob, -1, OCI_B_BLOB);
    oci_bind_by_name($stmt, ':file_id', $insert_id, -1, SQLT_INT);
    oci_execute($stmt,OCI_DEFAULT);
    In this case the last thing I do before the commit is
    $lob->save($contents);
    Both work fine, but what I need is this
    $contents = file_get_contents($_FILES["uploadedfile"]["tmp_name"]);
    $lob = oci_new_descriptor($conn, OCI_D_LOB);
    $stmt = oci_parse($conn,"BEGIN do_upload_file(:src_contents,'{$propername}',{$ownerid},:file_id); END;");
    oci_bind_by_name($stmt, ':src_contents', $lob, -1, OCI_B_BLOB);
    oci_bind_by_name($stmt, ':file_id', $insert_id, -1, SQLT_INT);
    oci_execute($stmt,OCI_DEFAULT);
    $lob->save($contents);
    oci_commit($conn);
    this omits error conditions (such as on $lob->save ... etc.) it is simplified.
    The content of the procedure I changed as follows, but it seems untestable.
    CREATE OR REPLACE PROCEDURE do_upload_file (src_contents IN OUT blob, canonical_name in varchar2, owner in number, file_id IN OUT number)
    AS
    dest_loc BLOB;
    begin
    insert into files values(owner,canonical_name,empty_blob(),files_seq.nextval) returning files.data, files.file_id
    into dest_loc, file_id;
    dbms_lob.open(src_contents,DBMS_LOB.LOB_READONLY);
    DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.COPY(dest_lob => dest_loc,
    src_lob => src_contents
    ,amount => DBMS_LOB.getLength(src_contents));
    DBMS_LOB.CLOSE(dest_loc);
    DBMS_LOB.CLOSE(src_contents);
    COMMIT;
    end;
    I don't get errors because I cannot figure out a way to run this procedure in my PL/SQL environment with valid data. (I can run it with a blank blob.)
    But when I work out the order of what's going on, it doesn't make sense; the commit in the procedure is before the $lob->save(...) and thus it would never save the data... nonetheless it should at least create a record with an empty blob but it does not. What is wrong is beyond the error level that seems to be supported by PHP's oci_error function (unless I have not discovered how to turn all errors on?)
    In any case I think the logic is wrong here, but I'm not experienced enough to figure out how.
    To test it I would need to create a driver that loads an external file into a blob, and passes that blob into the procedure. Trouble is, even if I make a blob and initialize it with empty_blob() it treats it as an invalid blob for the purposes of the dbms_lob.copy procedure.
    If someone has solved this problem, please let me know. I would love to be able to do the file upload with just a single procedure.

    Thanks. In my estimation that is exactly the issue. But that doesn't help with a resolution.
    The actual file size: 945,991 bytes
    If Firefox is miscalculating the length (in Safari/Chrome 945991 and 946241 in Firefox), then Firefox is reporting erroneously and should be raised as a bug in Firefox, would you agree?

  • Issues with file upload in flex mobile application (sharepoint as backend)

    Hello,
    I am working on flex mobile application for android platform for which we are having sharepoint as a backend.
    (Flex SDK 4.6 and AIR 3.9)
    Issue which we are facing is as follows:
    We are communicating with the backend server using webservices: example:
    <s:WebService id="kWebService" wsdl="http://www.kservice.net/kdatabaseservice.asmx?WSDL" >
                <s:operation name="AddPost"
                             resultFormat="object"
                             result="addPostResult(event)"
                             fault="postsfaulterr(event)" />
    </s:WebService>
    Above services are working fine but we are facing issue with one service which is related to file upload.
    File upload for <10 MB is working fine but when we try to upload larger file on server it fails to process.
    We are sending bytearray to the backend and backend code is writing those bytearray into file.
    We have tried many ways to overcome from this situation. like we have checked configuration for file upload size on server , we have tried wcf services as well. Please help us on this criticle point as soon as possible
    Thanks
    Dhwani

    Prashant8809 wrote:
    Hi
    >
    > I have already gone through the video by Thomas Jung for multiple file upload but it saves the contents in server and not in >transparent table. So please suggest me alternative solutions.
    >
    >
    > Regards
    > Prashant Chauhan
    What do you mean that my video saves the contents int he server and not in transparent table?  I save the data into a temporary database table so it can be accessed by the parent WDA session. From there the WDA session can do whatever it wants with it.  What do you mean by transparent table - that would be a database table. Do you actually mean internal table?  if so, just read the data from the temporary database table into memory.

  • File.upload on Air SDK for iOS devices failed to send http request to server.

    I am trying to use ActionScript's File.upload to upload a file on Air SDK for iOS8 environment, but the File.upload does not work properly. No handler about the file upload is executed after File.upload is invoked, and no exception is caught. When I check the network traffic of the server side, I found that no http request even hit the server after File.upload is executed. The code snippet here is very simple.
      private var file:File;
      private var dir:File;
      //This method is executed to create a file and upload it when the Upload Button is pressed.
      protected function OnUploadButtonPressed(event:MouseEvent):void{
      var str:String = 'This is test';
      var imageBytes:ByteArray = new ByteArray();
      for ( var i:int = 0; i < str.length; i++ ) {
      imageBytes.writeByte( str.charCodeAt(i) );
      try{
      dir = File.applicationStorageDirectory
      var now:Date = new Date();
      var filename:String = "test" + now.seconds + now.milliseconds + ".txt";
      file = dir.resolvePath( filename );
      var stream:FileStream = new FileStream();
      stream.open( file, FileMode.WRITE );
      stream.writeBytes( imageBytes );
      stream.close();
      file.addEventListener( Event.COMPLETE, uploadComplete );
      file.addEventListener( IOErrorEvent.IO_ERROR, ioError );
      file.addEventListener( SecurityErrorEvent.SECURITY_ERROR, securityError );
      file.addEventListener(ErrorEvent.ERROR, someError);
      file.addEventListener(ProgressEvent.PROGRESS, onProgress);
      file.upload( new URLRequest("http://10.60.99.31/MyPath/fileUploadTest.do"));//This line does not work. No handler is executed. No http request hit the server side.
      } catch( e:Error ) {
      trace( e );
      //Complete Handler
      private function uploadComplete( event:Event ):void
      trace( "Upload successful." );
      //IOError handler
      private function ioError( error:IOErrorEvent ):void
      trace( "Upload failed: " + error.text );
      //SecurityError handler
      private function securityError(error:SecurityErrorEvent):void{
      trace( "Security error:" + error.text );
      //Other handler
      private function someError(error:ErrorEvent):void{
      trace("some error" + error.text);
      //Progress handler
      private function onProgress(event:ProgressEvent):void{
      trace("progressHandler");
    When executed on Air Simulator, it works fine as expected, and the file is successfully uploaded to the server. But When executed on iOS devices(in my case, iPad), as I explain early, no handler about the file upload is executed, and no the http request even hit the server. So I think the problem may be in the client side. It seems that the Air SDK for iOS just failed to send the http request for some reason.
    To make my problem more clear, I list my environment below:
    Development Environment:  Windows7 (64bit)  / Mac os 10.9.4 (Tested on  OS platforms.)
    IDE: Flash Builder 4.7
    Air SDK:  3.8 / 16.0.0 (After I updated to the lastest Air SDK 16.0.0 , the problem still exists.)
    Application Server:  Tomcat7 + Spring
    Target OS: iOS 8
    I have been struggling for this for days. So I really appreciate it if anyone has any idea about this.
    Thanks in advance.

    Hi bluewindice ,
    As you have quoted ( ActionScript's File.upload does not work on Air SDK for iOS devices ) , this issue has been replicated at our end, and our team will be working on it.
    Thanks,
    Tushar

  • When I use FTPFire the .htaccess file uploads as hidden. How do I unhide it once it is uploaded?

    My .htaccess file shows live on my c drive... When I upload it to my web host, it loads as hidden...
    How can I unhide it once it is uploaded?

    That is the purpose of that file. On Linux a file that start with a dot is a hidden file and there is no need to see that file anyway because it is meant for controlling the server behavior. I assume that FireFTP has a setting to show hidden files that you need to enable if you do not see the file.

  • Tomcat file upload

    Hi, I'm having a problem with file upload.
    I've try to use oReilly classes, but I've had problems.
    So I've try to use a small package from com.bigfoot ( he's probably a student) for multipart form.
    All works well with tomcat 4.0 on win2k.
    When I deploy the application under Linux 7.2, Tomcat 4 and Apache ... problems begins :-(((((
    During ServletInputStream reading, I think, something goes wrong. Some bytes are read ... then the stream seems to empty ... and the reading process crashes.
    What can I do ????

    I'm sorry I've change my account so look the newer message from alexdonato.

Maybe you are looking for

  • Reading binary data from a URL

    Below are 2 snippets of code that read data from a binary file. A small sample of the output is shown at the bottom of each code fragment. The first one uses the URL class to read a remote file. The ouput for this fragment is incorrect in some cases.

  • Page Header Not at Top of Bookmarked Page

    Using Report Builder 3.0 I have a large multipage report that has a Report Header which includes "tabs". The tabs are links to Bookmarked pages. I need the Report Header to display at the top of each page when a tab is clicked. To understand the stru

  • Flex Mobile Images

    Hi, I am unable to see my Images in the adobe flex mobile project. I am able to see the picture before load but once the program is run the image disappears? I have tried changing the picture. The source path and the source path in source code. I rea

  • Mounting drives after server reinstall

    Hi, I am about to reinstall/upgrade my server. I have had a problem several times in the past, where I have done this, and then am not able to mount the old drives. Whenever I have reinstalled Mac OS X Server (10.4.1), the arrays will show up properl

  • Paymeent block

    Warm greetings to all!, While using Specail GL indicator system is also using payment block field by default.Even if i try to remove it still it picks up the value in payment block field. Pls guide me suitable solution. Immediate reply will be apprec