Upload multiple files in jsp using input file

hi i have been trying to upload multiple 3 iamges max into the server.by adding the path into the database.
<%@page import=" java.io.*"%>
<%@page import=" javax.servlet.*"%>
<%@page import=" javax.servlet.http.*"%>
<%@page import=" java.sql.*"%>
<%response.setContentType("text/html");
String pid = request.getParameter("id");
System.out.println(pid);
int propid=Integer.parseInt(pid);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn= DriverManager.getConnection("jdbc:odbc:rama");
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;
String file = new String(dataBytes);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
saveFile=saveFile.substring(saveFile.lastIndexOf("."),saveFile.length());
saveFile= pid + saveFile;
//out.print(dataBytes);
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;
String saveFilepath="upload/" + saveFile;
FileOutputStream fileOut = new FileOutputStream(saveFilepath);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();%>
          <center>     
          <table border="4" width="50%" bgcolor="#2C9FE6" bordercolor="#3C6B9E" id="table16">
                    <tr>
                         <td><%out.println("File saved as " +saveFile);%></td>
                    </tr>
               </table></center><br>
<%
Statement st=conn.createStatement();
int q=st.executeUpdate("update addprop set imagepath='"+saveFilepath+"' where propid="+propid+" ");
System.out.println(q);
%><%}%>
this code uploades one image i want to upload max 3 how to do itt help

Hi Sandesh,
this is simply not supported, not in WebDynpro nor in standard HTML.
A workaround is to upload a ZIP with all files and on server side unpack the ZIP and operate on the single files.
I hope it will  help u..
----------------------OR-------------------------
As you know using File upload UI element we can upload only one file at a time. There may be a scenario where user may want to upload any no of files at a time which is not determined at design time. This can be acheived using the ACF UpDownload UI element which requires a security whiltelist to be created
http://scn.sap.com/docs/DOC-2270
----------------------OR-------------------------
You can use Table UI element.
Regards,
Deepak Singh

Similar Messages

  • Problem loading resources file in JSP using f:loadBundle

    Hi,
    We are facing problem while loading our properties file in JSP using f:loadBundle.we tried the following way
    <f:loadBundle basename="resources.ApplicationResource" var="msg"/>
    This properties file is src java folder and also in WEB-INF-->classes->resources folder
    but even then its not able to load.I made an entry in the faces-config for message-bundle. But of no use.
    Any pointers would be of great help.

    does your file calls
    ApplicationResource.properties ?
    If so is it in
    the package resources ?

  • How do I get files from multiple DVDs that are using thesame file names?

    How do I get files from multiple DVDs that are using thesame file names? Message says "file already exists in catalog"
    Message was edited by: marcr56

    marcr56
    I am viewing your question from different perspective, that is, the issue that you face when you are ripping VOBs from a second DVD-VIDEO on DVD disc using Premiere Elements,
    It is best to give the Premiere Elements version and computer operating system that it is running on. In the absence of that, I will generalize.
    Assuming that you are using
    Premiere Elements 12
    Add Media
    "DVD Camera or Computer Drive"
    Video Importer
    Typically the Video Importer Save In: is C:\Users\Owner\Videos
    Each of your DVD discs is going to have the same names for the ripped VOBs (VTS_01_1.VOB and so on depending on the duration of the movie). Consequently, after the ripping of the first DVD's VOBs and their save to Videos, you will end up with that "files already existing..." block for the ripping of the VOBs from the second DVD.
    The answer is, for each DVD disc VOB ripping, to plan ahead and create and set for different folders in Videos in the Save In field of the Video Importer.
    Please review and then let us know if that works for you. Please do not hesitate to ask if you need clarification on anything that I have written.
    Thank you.
    ATR.

  • I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    Logged the call with SAP who directed me to 'Define settings for attachments' in IMG and setting the 'Deactivate Java Applet' & 'Deactivate Attachment versioning' checkboxes - problem solved.

  • PI needs to obtain a zip file via FTP using the File adapter

    I have a scenario where PI needs to obtain a zip file via FTP using the File adapter, this zip file contains a number of txt files that I need to process, and the content of one of them send it to an ECC, now I'm using the PayloadZipBean Module in the Sender FIle Adapter, and I have two things if I use the Message Protocol as File, I get a Payload for each txt file in the zip file, but this payload has no structure, and if I use the File Content Conversion I get an XML strcuture with only one field and a strange string in it, and somewhere in this string the names of the files I assume all the content of the zip file, can anyone help on how could I achieve what I need that is to pull the zip file via SAP PI, then unzip it, and with the content of one of the txt files send it to an ECC via ABAP Proxy, thanks in advance for your answers.
    Regards,
    Raul Alvarado

    Hello Raul,
    you can do it in futher way ...
    pickup zip file and simply extract and dump it in another temp folder (can use scripts on OS level).
    @ then Use another sender communication channel to pickup all these text file .
    for further clarification you can use these links also. -
    Process txt files in zip file
    Accessing File using FTP from Java Mapping
    File Sender Adapter with FTP protocol
    BR
    Raj

  • Uploading multiple items one at a time - file view resets

    In my work, I need to upload many files, one at a time, using an interface through the browser.
    When I go to upload multiple files, one at a time, using 10.6.2, the Finder takes me back one or two levels down from the file location between uploads. In 10.4, the Finder always took me back to the folder last accessed.
    Is there a Preference, Shareware like TinkerTool, or a Terminal Command I can use so that I always go back to the folder last accessed?

    OK. Wow. I did not realize the question was so obtuse. Feel free to ask for clarification (no reason to be nasty or flame me).
    "what mechanism is being used"
    In my original post, I did say I was uploading via a browser. So I don't know if this clarifies for you or not.
    Using Firefox or Safari.
    Uploading photos, one at a time, to a website that uses the browser (rather than FTP).
    In OS 10.4.11, after each photo, I would upload a second one and the dialog box would open up to the same folder as the previous upload, greatly simplifying the process.
    In OS 10.6.3, after each photo, I would go to upload a second photo and the dialog box would open one level down, or sometimes seemingly randomly, two levels down. This requires me to navigate back to the folder with the photos which greatly increases the amount of time between each upload.
    It would be helpful if I could show photos to explain.
    I am not certain that this really clarifies my original posting. Does this make sense or do you need more info?

  • Check IN a file from local user machine using Input file tag

    Hi
    We have created a webapplication using Oracle UCM. We have designed certain forms and want to give users an input field to upload images to content server.
    I included a input type file tag in my form and on submit redirected to a JSPX.
    I included on JSPX following tag when the form is submitted as follows
    <wcm:idcService service="CHECKIN_NEW_FORM" var="fileUpload">
    <wcm:idcParameter name="doFileCopy" value="1"/>
    <wcm:idcParameter name="dDocName" value="Test_Aakash"/>
    <wcm:idcParameter name="dDocTitle" value="Test_Aakash"/>
    <wcm:idcParameter name="dDocType" value="Document"/>
    <wcm:idcParameter name="dSecurityGroup" value="Public"/>
    <wcm:idcParameter name="dDocAuthor" value="anonymous"/>
    *<wcm:idcParameter name="primaryFile" value="C:/test.txt"/>*
    </wcm:idcService>
    I was hoping to pass primary path that a client will specify will allow the file to check in to the UCM server.But, to my dismay the tag expects that primary file be the path of file present on the Server and not on client machine accessing the webapplication.
    How can I check in file from client local machine to UCM server. I found default IdcService=CHECKIN_NEW_FORM through web-application allows one to select primary file from his local machine. But, this not the case when i do the same using the tag above. Please help how can i achieve the desired result.
    Thanks,
    Aakash
    Edited by: 856575 on Jul 19, 2011 12:31 AM
    Edited by: 856575 on Jul 19, 2011 12:32 AM

    Hi
    We have created a webapplication using Oracle UCM. We have designed certain forms and want to give users an input field to upload images to content server.
    I included a input type file tag in my form and on submit redirected to a JSPX.
    I included on JSPX following tag when the form is submitted as follows
    <wcm:idcService service="CHECKIN_NEW_FORM" var="fileUpload">
    <wcm:idcParameter name="doFileCopy" value="1"/>
    <wcm:idcParameter name="dDocName" value="Test_Aakash"/>
    <wcm:idcParameter name="dDocTitle" value="Test_Aakash"/>
    <wcm:idcParameter name="dDocType" value="Document"/>
    <wcm:idcParameter name="dSecurityGroup" value="Public"/>
    <wcm:idcParameter name="dDocAuthor" value="anonymous"/>
    *<wcm:idcParameter name="primaryFile" value="C:/test.txt"/>*
    </wcm:idcService>
    I was hoping to pass primary path that a client will specify will allow the file to check in to the UCM server.But, to my dismay the tag expects that primary file be the path of file present on the Server and not on client machine accessing the webapplication.
    How can I check in file from client local machine to UCM server. I found default IdcService=CHECKIN_NEW_FORM through web-application allows one to select primary file from his local machine. But, this not the case when i do the same using the tag above. Please help how can i achieve the desired result.
    Thanks,
    Aakash
    Edited by: 856575 on Jul 19, 2011 12:31 AM
    Edited by: 856575 on Jul 19, 2011 12:32 AM

  • How to include HTML file in JSP using HTML elements or Javascript?

    Hi,
    I have around 15000 static html files one for each item which we display each upon invoking an item.The HTML file should be part of a JSP file.
    Please note that the name of the HTML file is determined dynamically
    Placing all the HTML files within the web application does not give us good performance so i would like to put all of them in the webserver.
    I am not able to include the file in the JSP using the jsp:include attribute if i place the HTML files in the webserver ,
    in order to do that i think should use either HTML element or javascript to include the HTML in the JSP.is there any alternative to <Jsp:include>
    Does anyone have an idea how to include the HTML file and take advan tage of webserver?
    Any ideas are appreciated

    What you need to do is simply read the HTML file from the disk and dump it out to the outputstream. It really is that simple.
    There's no reason you need to include all 15000 files in the actual WAR, you can place those files any place handy that is easy for the application to see (in another directory, or accessible from a file server if you have multiple front ends).
    Then, just write a utiility function that takes the output stream (i.e. the 'out' JSP variable), and the file name, read the file, and write it to the stream.
    If you start noticing performance issues, then you can try doing some caching, but truth is your OS should be doing that for you.
    But, truth be told that's the only practical way to do it.
    Another solution would be to use JavaScriipt and XMLHttpRequest (i.e "AJAX") to load the file at the client side, and simply replace a tag with the results.
    That's also pretty trivial to write, any web site talking about AJAX should give you hint there.
    Of course, that won't work for folks who have JavaScript turned off, or some other incompatible browser, whereas the server side solution obviously works everywhere.

  • How to display the data in XML files into JSP using Jdeveloper.

    Hi All,
    I have two XML files one XML file has the view names and the other has the table names of a particular views, how to display the data in JSP using JDeveloper where when i click a particular view the list of tables of that particular view from XML file two should be displayed in JSP Page.
    Are there any reference documents, regarding the above process please can anyone guide through how to do it.

    Let the servlet ask your business tier to provide the data, then stuff it into beans, and pack those into the Session instance. Then forward the request to the JSP, let the JSP get those beans and display them.

  • After uploading file in BLOB using webutil file on system locked?

    I uploaded file in BLOB using webutil upload utility. But after uploading it locks the file and i cannot delete the file unless i close the iexplorer window.
    Is there any way to unlock the file and delete it with out closing the application(iexplorer). If any body knows please reply.
    Regards,
    Muhammad Qazzafi

    can you post the statements, which you use for the upload ?
    thx
    Gerd

  • Handling files in JSP(using TOMCAT engine)

    Hi
    I am calling a text file,which contains the details of the database variables(like the ip of the database server, the username and the password of the database) from one of my JSP pages. I have added this text file at 2 places , one in the BIN folder of my APACHE TOMCAT folder, another in the same folder from where i am running my .JSP file.
    But its not working .. it gives an error..."The system cannot find the file specified" i.e. The Text File.
    Help//

    try this
    File f = new File(application.getRealPath("connect.properties"));

  • Require output file name same as input file without extension

    I am doing a POC where I require that my output file name should be same as input file name. The input is a XML and output is Flatfile. If I use %SourceFileName%,
    i am getting the output with extension. How can I remove the extension? Do I need to write a custom pipeline component?

    I don't think Orchestration or custom Pipeline can help you on this as  you are setting
    %SourceFileName% Macros at your send Handler which comes after Pipeline Processing .
    As you are converting xml file to Flat file I would suggest to use  Macros  as
    %SourceFileName%.txt 
    %SourceFileName% Macro gives the file name along with extention. This won't work!

  • Use preview files unchecked, but uses preview files?

    Premiere Pro CS4 running on Windows XP MCE SP3 on a core two duo processor (Yes, I know it is underpowered, but it works well enough for my current projects) and a three internal HDD setup.
    When exporting to mpeg2 - DVD I make sure to check "maximum render quality" and uncheck "use preview files".
    I noticed that if the timeline is rendered before export, then a one minute video will complete export in about one minute.
    If the timeline is left unrendered before export, however, the export will take about twenty minutes.
    I thought that the export is not affected by whether or not the timeline is rendered as long as preview files are not used.
    Am I mistaken, or is something not right?

    If Use Render Files is unchecked, then the program should not be using them. With MPEG-2, there is not really that much that can be gained, as the Render files are AVI.
    Also, what are the specs. of the Clips on the Timeline?
    I would check things like the WAB (Work Area Bar), just to make sure that you are seeing apples vs apples, so to speak.
    Good luck,
    Hunt

  • What type of file can be used with file generator in Motion 4?

    Regarding using the File Generator in Motion 4, what type of file can be used? After clicking the browse button in the inspector tab,
    all files appear greyed out and are not selectable.
    Thanks!
    Richard

    Cool. Thanks GFXZen. I was stumped by TextEdit saving files in rich text format. Here is an article on how to save in plain text from TextEdit:
    http://support.apple.com/kb/TA20406

  • How can i upload multiple pictures on facebook using the ipad 2? Because i've tried uploading before but it should be one by one. Please help.

    Thankyou.

    How are you accessing facebook? I do it through Safari and can upload multiple pics. Are you doing that or through the app?

Maybe you are looking for

  • Skype keeps crashing

    Hi Skype keeps on crashing have tried reinstalling several times. See below for problem details. Also please see attachment, any ideas? Problem signature:   Problem Event Name:    BEX   Application Name:    Skype.exe   Application Version:    7.6.0.1

  • Problem Updating CS6

    I gen an error when I try to upload CS6 - using OS X 10.8.4 DPS Desktop Tools CS6 27.0.0 Update Installation Successful. Error Code: U44M1I0 Adobe Bridge CS6 5.0.2 Update Installation Successful. Error Code: U44M1I0 Photoshop Camera Raw 8.1(CS6) Inst

  • SIP invite error on UC520

    Am setting up a SIP trunk on a UC520.  Outbound calling is working fine.  Inbound is not. The SIP invite comes in but is rejected with a: SPI_validate_own_ip_addr: ReqLine IP addr  does not match with host IP addr I suspect this is caused by the fact

  • I need 1.6.34 or 1.6.37 for Mac OSX.

    Hey folks. I currently have java 1.7 installed on my machine. I need to remove this and install either 1.6.34 or 1.6.37 . Its for an Oracle issue. Can anybody advise me how i can remove the Java version and where i can download 1.6.34. I did google i

  • PS and FICO in one system, payroll in other - payroll posting run fails

    Hi, We are a system solution is which one server contains FICO, PS, MM, SD Travel, CATS and mini-HR. The other has mini-FICO, HR and payroll. System is 604 SP36. We don't want to have the PS conifguration in HR server but we need to have travel costs