Upload media file and submit data in a same time

Hi,
I'm trying to submit data and upload file in a same time to a web page(which is jsp). But i found that the method used to upload file and submit data are different.
Method used to submit data :-
PostMethod post = new PostMethod(wbIndex);        
post.addRequestHeader("Content-Type","text/html; charset=big5");
for(int i=0;i<field.length;i++){
     post.addParameter(field,value[i]);
System.out.print("field[" + field[i] + "], value[" + value[i] + "] ");
responseCode = client.executeMethod(post);
System.out.println("response code : " + responseCode);
and method used to upload file
URL url = new URL(wbIndex);
// create a boundary string
String boundary = MultiPartFormOutputStream.createBoundary();
URLConnection urlConn = MultiPartFormOutputStream.createConnection(url);
urlConn.setRequestProperty("Accept", "*/*");
urlConn.setRequestProperty("Content-Type",
     MultiPartFormOutputStream.getContentType(boundary));
// set some other request headers...
urlConn.setRequestProperty("Connection", "Keep-Alive");
urlConn.setRequestProperty("Cache-Control", "no-cache");
// no need to connect cuz getOutputStream() does it
MultiPartFormOutputStream out =
     new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
// write a text field element
out.writeField("myText", "text field text");
// upload a file
out.writeFile("myFile", "text/plain", new File("C:\\test.wav"));
out.close();Does anyone know how to submit data and upload file to the page at a same time?
null

Hi,
Thanks for your reply. You meant that both method also can used to upload file and submit data? How about if i want to use the first method to upload file and submit data? How can i upload the file by using first method?

Similar Messages

  • How can I do to acquire and save date in the same time and in the same file when I run continual my VI without interrupti​on.

    I've attached a VI that I am using to acquire amplitude from Spectrum analyzerse. I tried to connect amplitude ouput to the VI Write Characters To File.vi and Write to Spreadsheet File.vi. Unfortunately when I run continual this VI without interruption, labview ask me many time to enter a new file name to save a new value.
    So, How can I do to aquire and save date in the same time and in the same file when I run continual my VI for example during 10 min.
    Thank you in advance.
    Regards,
    Attachments:
    HP8563E_Query_Amplitude.vi ‏37 KB

    Hi,
    Your VI does work perfectly. Unfortunately this not what I want to do. I've made error in my last comment. I am so sorry for this.
    So I explain to you again what I want to do exactly. I want to acquire amplitude along road by my vehicle. I want to use wheel signal coming from vehicle to measure distance along road. Then I acquire 1 amplitude each 60 inches from spectrum analyzer.
    I acquire from PC parallel port a coded wheel signal coming from vehicle (each period of the signal corresponds to 12 Inches). Figure attached shows the numeric signal coming from vehicle, and the corresponding values “120” and “88” that I can read from In Port vi.
    So I want to acquire 1 time amplitude from spectrum analyser each 5
    period of the signal that I am acquiring from parallel port.
    So fist I have to find how can I count the number of period from reading the values “120” and “88” that I am acquiring from In Port (I don’t know the way to count a number of period from reading values “120” and “88”).
    Here is a new algorithm.
    1) i=0 (counter: number of period)
    2) I read value from In Port
    3) If I acquire a period
    i= i+1 (another period)
    4) If i is multiple of 5 (If I read 5 period)
    acquire 1 time amplitude and write to the same
    file this amplitude and the corresponding distance
    Distance = 12*i). Remember each period of signal
    Corresponds to 12 Inches).i has to take these
    values: 5,10,15,20,25,35,40,45,50,55,60............
    5) Back to 2 if not stop.
    Thank you very much for helping me.
    Regards,
    Attachments:
    Acquire_Amplitude_00.vi ‏59 KB
    Figure_Algorithm.doc ‏26 KB

  • Upload file and update text at the same time

    I wanted upload a file and i have text box also, i know how
    to upload a file but the problem i cannot update the text box at
    the same time can anyone share how, I'm using the
    ASPSimpleUpload.Upload.
    please helpe thanks

    Do you mean something like this?
    SQL> create table table_name
      2  (column_a number
      3  ,column_b number
      4  ,column_c number
      5  ,date_column_d date
      6  );
    Table created.
    SQL>
    SQL> insert into table_name values (0,0,0,sysdate);
    1 row created.
    SQL> insert into table_name values (1,1,1,sysdate);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> create view view_name
      2  as
      3  select
      4  column_a,
      5  column_b,
      6  column_c,
      7  case when column_c = 1 then to_date('01-JAN-1900','DD-MON-YYYY')
      8       else date_column_d
      9  end  date_column_d
    10  from
    11  table_name;
    View created.
    SQL> select * from view_name;
                COLUMN_A             COLUMN_B             COLUMN_C DATE_COLUMN_D
                       0                    0                    0 12-DEC-2008 07:42:15
                       1                    1                    1 01-JAN-1900 00:00:00Edited by: SomeoneElse on Dec 12, 2008 7:42 AM

  • Uploading Excel File and Reading Data from that File

    <b>Hi
    Can anyone Please tell me how to upload an Excel File in to the Web Dynpro Application and After that i want to read the data from that uploaded excel file in the Web Dynpro Application to the Web Dynpro table.
    Plz help me to solve this.......
    Regards
    Chandran</b>

    Hi,
    Upload Excel file using File Upload UI
    1)Add jxl jar folder in the lib folder of ur project.
    2)Go to properties of ur project and add jar to ur project.
    3)Using the File upload ui ,browse and upload the file.
    4)Write the read file in to ur server location using fileoutput stream.
    5)then using code u can read the excelfile from the server location itself.
    Here is the code:
         IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
    /** get the name of excel file and storing it in the server with the same name and extention****/
    binaryType=IWDModifiableBinaryTypeattInfo.getModifiableSimpleType();
    fileuploaded = binaryType.getFileName();
    byte b[] = wdContext.currentContextElement().getUpload();
    File filename =new File("
    <Server name>
    <folde name>
    " + fileuploaded);
    try {
    FileOutputStream out = new FileOutputStream(filename);
    out.write(b);
    out.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    /**Readind from the server**/
    int iRows = 0;
    try {     Workbook wb = null;
         Sheet sheet = null;
         wb = Workbook.getWorkbook(filename);
         sheet = wb.getSheet(0);
         int iColumns = sheet.getColumns();
          iRows = sheet.getRows();
         int i = 0;
        //get Cell contents by (COLUMN, ROW);
        for (int r = 0; r < iRows; r++) {
       for (int c = 0; c < iColumns; c++) {
         Cell cell = sheet.getCell(c, r);
         characterarray<i> = cell.getContents();
    //wdComponentAPI.getMessageManager().reportSuccess("Row"r characterarray<i>);
    i++;
    wb.close();
    Declare Globally
    //@@begin others
    String fileuploaded;
    IWDModifiableBinaryType binaryType;
    String characterarray[] = new String[1000];
    //@@end
    Also look at this blog too  /people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
    Thanks and Regards,
    Arun

  • Problem !! How to upload an file and get parameters on the same form ?

    Hello!
    Is there anyway of getting parameters from an
    text field input in a form like :
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
    on the same form. It is something likethis :
    Form.jsp
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >   
    <input type="text" id="name" name="signinName" />
    <input name="signinFile" id="fileUp" type="file" />   
    <input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
    <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
    <%@ page import="java.io.FileWriter,java.io.IOException" %>
    <%
    .//upload the file
    String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
    %>Thanks in advance for any suggestion!!
    All the best!

    You can get the parameter value directly. You can do the following to get the parameter name.
    Directly take the request's input stream and parse the header and findout the value for text field.
    Or you can use apache's file upload utilities and do the following
    DiskFileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List fileItems = upload.parseRequest(request);
                   Iterator iter = fileItems.iterator();
                   while (iter.hasNext()) {
                        FileItem item = (FileItem) iter.next();
                        if (item.isFormField()) {
         //Form data fields will be displayed here          out.println(item.getFieldName());
         out.println(item.getString());
    All the best..

  • Cant add files and use itunes at the same time?

    I am totally confused as to why Itunes is Frozen when im adding files. I usually manually add my music to itunes myself. I figured why not take advantage and just have it do it for me. Now i cant play or pause the music as its doing this. The main problem is that the folder of music that i added, has all my itunes files on that drive in that folder. Is it going to add everything i have twice now? its telling me new versions of apps are available. I have 600+ apps. Im starting to realise that there is no work around for this. perhaps this belongs in a suggestion thread. sorry for ranting. delete this post its looking like i have to force itunes closed and ruin everything that i have organised so i dont have to tell itunes 600 times that i dont want to find the new version of an app. I've already been fooled into recrediting all my downloads because Everyone wanted to play stupid on the phone. GOD HELP ME!

    Say i finish clicing x 600 times. Is there a way to stop the music after it resumes searching my 111 gb of music. i dont want to play the same cd the whole time.

  • Upload unicode file and display content in a textarea

    Hi all,
    I am trying to do the following;
    1. upload a unicode file (file with some non-english characters)
    2. after uploading, read the uploaded file and show the content in a textarea in a jsp page.
    I use struts in my project. I use class org.apache.struts.upload.FormFile for uploading the file. The upload works fine. I do the upload with help of FormFile's getInputStream method. When i read and display the content in the textarea, the content is displayed junk. But i tried to open the uploaded file, its fine. I mean it is just as my source file. Please help me out for reading the uploaded unicode and displayed in a textarea.
    Below is the code that i use to upload the file;
    File tempFile = null;
    FileOutputStream fos = null;
    InputStream is = null;
    try {
         tempFile = "c:/ThaiText.txt";
         fos = new FileOutputStream(tempFile);
         is = theFile.getInputStream();
         // Transfer bytes from in to out
         byte[] buf = new byte[1024];
         int len;
         while ((len = is.read(buf)) > 0) {
              fos.write(buf, 0, len);
         logger.info("fileName$$=" + tempFile.getName());
    } catch (Exception e) {
            logger.error(e);
         throw e;
    } finally {
         closeOutputStream(fos);
    }Below is the code that i use for reading the uploaded file's content and store it to a string. I set this string to a form bean's string property.
    public static String readContentNonUTF8(String path) {
         FileInputStream fis = null;
         String value = "";
         try {
              fis = new FileInputStream(path);
              byte[] buf = new byte[1024];
              int len;
              while ((len = fis.read(buf)) > 0) {
                   String tmp = new String(buf, 0, len);
                   value = value.concat(new String(tmp.getBytes()));
         } catch (Exception e) {
              logger.error(e);
         } finally {
              try {
                   fis.close();
              } catch (Exception e) {
         return value;
    }

    Hi,
    Thanks for your reply. You meant that both method also can used to upload file and submit data? How about if i want to use the first method to upload file and submit data? How can i upload the file by using first method?

  • Advice on uploading files and process data

    Hi, I'm building an Apex application. It requires that users can sometimes upload data (csv) that will be validated and inserted into the database.
    For now I've created a component that uploads the file and copy it to my UPLOADED_FILES archive table as a blob. Now I need to create a process that review data from blob and, if posible, inform the user of incorrect lines.
    It seems that I need to recreate the file on the oracle server from the blob, then use SQL Loader to create an external table from that file and finally run my own validate/copy procedure over the external table data.
    So my questions are:
    - Is there a more proper way of doing this?
    - Can I create the external table directly from the blob, without recreating the file, and an oracle directory?
    - When using sql loader, how can I deal with quotes in the text? (the csv is generated from an spreedsheet, it can have text data with quotes that will be scaped, so a posible line will be (three fileds separated by semicolons):
    my data 1;"my data 2""some escaped quotes here""and a semicolon inside ; my data 2 final";my data 3;
    Will work the declaration: fields terminated by ";" optionally enclosed by '"' ?
    note '"' = apostrophe+quotation+apostrophe
    Thanks for your advice.

    user3917161 wrote:
    It seems that I need to recreate the file on the oracle server from the blob, then use SQL Loader to create an external table from that file and finally run my own validate/copy procedure over the external table data.
    So my questions are:
    - Is there a more proper way of doing this?The only other option is to manually parse the LOB yourself. So until Oracle provides external tables on LOBS too, this approach of writing it to external file for loading as an external table is a necessary evil.
    - Can I create the external table directly from the blob, without recreating the file, and an oracle directory?No.
    From Oracle® Database Administrator's Guide:
    "<i>Oracle Database provides two access drivers for external tables. The default access driver is ORACLE_LOADER, which allows the reading of data from external files using the Oracle loader technology. The ORACLE_LOADER access driver provides data mapping capabilities which are a subset of the control file syntax of SQL*Loader utility. The second access driver, ORACLE_DATAPUMP, lets you unload data—that is, read data from the database and insert it into an external table, represented by one or more external files—and then reload it into an Oracle Database.</i>"
    Perhaps we'll get a 3rd access driver in future that either supports LOBs, or enables us to define our own access driver (all that is needed as output from the driver is text lines - and this should not be that difficult to standardise as a custom interface to implement).
    - When using sql loader, how can I deal with quotes in the text? (the csv is generated from an spreedsheet, it can have text data with quotes that will be scaped, so a posible line will be (three fileds separated by semicolons):
    my data 1;"my data 2""some escaped quotes here""and a semicolon inside ; my data 2 final";my data 3;
    Will work the declaration: fields terminated by ";" optionally enclosed by '"' ?
    note '"' = apostrophe+quotation+apostropheBest is to try it and see whether it works. Also refer to the Oracle® Database Utilities for SQL*Loader syntax and options.

  • Uploading Media file to database

    Hi experts,
    I am able to load image file jpeg..etc to the database and display on jsp page from the database.
    Can anyone please help me with uploading media files like video, mp3, wav files to database.
    Please help...
    Thanx
    Deepak

    what is the difference between any type of file and an image? It is all binary data with a certain content-type.

  • Upload csv file and insert into a table for user

    Hello,
    i want to create a Page on which, the User of my Application can upload a semicolon delimited file and the data of the file should automatically be stored in a table.
    I can upload the file and the file is then stored in the htmldb_application_files table.
    But I do not no how to parse the file....
    Can anyone help me or is there anyone who have done that before?
    Thank you,
    Tim

    Tim...
    Here is what I did in a similar situation.
    Let the user download a csv file to use as an excel turnaround document.
    I check digit the primary key. They are not supposed to touch that column.
    They do their excel thing adding data in columns next to the ones they are updating. They now have the original and new data on the same row in the excel document. They save it on a share drive as a csv. A perl script wakes up and parses the csv. Verify's the check digit, checks that the old values still exist in the table... etc, and then does the update if all is well at the row level. The csv is replaced showing the success or failure of the update on each row.
    Probably lots of other ways to accomplish this but I have gotten years of use out of the script. The original csv can come out of almost any application. Mine come from apex, discoverer and some excel queries.
    Bob

  • Upload excel file and display content in sapui5 table

    hi:all
       how to upload  excel files and display its contents in the view of sapui5  table ,then  'create ' these data into the abap database using odataservice.
         Do you have any solutions ? I appreciate for your help.

    Two possible way come to mind.
    1. ADF DI (desktop integration): sorry, don't know enough about it to give a how to :-(
    2. POI (http://poi.apache.org/) : open source project to read and write excel file with java. Using POI you can open the .xsl file, read it's contents and display it as af:table. For this you need to read the xsl into a data structure (this can be a temporary db table or a list of POJOs) and build a data control out of it. This you can drop on a page as table.
    Timo
    Edited by: Timo Hahn on 15.02.2010 13:59

  • Archive a playlist with media files and the song settings

    I want to remove a body of songs from out of my library (Holiday and Christmas -- surprise, huh?) and yet have it ready to reimport next November, complete with song settings -- for example, I go through and amend the play volumes rather than using Sound Check.
    If I delete the songs from my main library, but keep files, I realize I still have them, but do I have to go back into my folders next year and find all the songs again? ... by Artist, I guess, since that's how the folders are organized.
    One year I burned the Holiday playlist with the media files as a data CD, and that worked okay, but didn't retain the individual volume adjustments I'd made.
    Thanks

    Are you trying to add songs to a smart playlist? If so that would explain the behaviour. To add songs to a smart playlist you need to adjust the rules or modify the tag so that it meets existing criteria.
    tt2

  • Create BDC group per uploading excel file to fill data in Tcode FB01l

    hi experts,
    i'm using BDC to run T-code FB01L . for this i'm uploading excel file for input data. my requiremenr=t is as follows : "
    only one BDC group should be created per uploading file."  But  At this moment BDC group is created per document. For user it is not possible to handle, say 1000 BDC groups.
    please suggest.
    Thanks
    Deepika

    The answer is simple and you should be able to work it out yourself but I am feeling generous today.
    I am assuming that each line in your excel spreadsheet is a document. The easiest way to do this is simply build up youd BDC table first then create the group.
        <- build your bdc table before opening the group ->
        call function 'BDC_OPEN_GROUP'
          exporting
            group = p_group
            keep  = p_keep
            user  = p_uname.
        call function 'BDC_INSERT'
          exporting
            tcode            = 'FB01'
          tables
            dynprotab        = gt_bdcdata
          exceptions
            internal_error   = 1
            not_open         = 2
            queue_error      = 3
            tcode_invalid    = 4
            printing_invalid = 5
            posting_invalid  = 6
            others           = 7.
    call function 'BDC_CLOSE_GROUP'
    In the future please do a search on SDN. I have also moved this thread to the ABAP General forum as this is not related to ABAP OO.

  • I am writing an interactive book and want to use media files and stuff.

    I am writing an interactive book and want to use media files and stuff. My question is: If I want to sell this book in the iBookstore,
    may I use photos I find on google images and media i find on youtube? Or must all be my own stuff?

    No !  well not just any photo image or "media". The person who created the photo images has a copyright protection IF  he/she wishes to impose it - ditto video and other  media.
    However if its out of copyright by  virtue of age and certain other factors - its considered in "The Public Domain" which is why you see paintings by the Impressionists all over chocolate boxes and posters to name but two!
    There are websites offering images donated by the creators and all for free.
    Taking and using a picture you do not own copyright and placing online where it can be downloaded is  first "publishing" and you  need permission and placing in a situation where it can be copied and re-distributed is a breach of copyright.
    Look at the  tail end credits on any DVD...  the above is always  included.
    Others rmay  correct me but Copyright in some countries is vaild from creation until 50 years after the death of the creator. However, that is not always the case.  Example, assume I am bequeathed a photo archive and on the  last day year 50,  I  publish a completely new version of the archive, wizzed through Photoshop, cleaned, cropped and modified in other ways.. then I can assert my claim for copyright of the renewed archive, but its a bit more complicated!!!
    You can search for "Free Photo Images (  media) , or royalty free images and if you land on a particular website you can ask permission. If you send me a request, my reply will be NO... and you get a warning of dire consequences if your infringe my copyright!  Other may be more lenient and in fact feel pretty good to be  asked.
    A way to get some guidance is to check out Wikipedia and the many  images included in its subject matter, check out the copyright status.
    Beware of using  photo images of paintings in  Galleries and Museums, they may have copyright conditions.. but one can always contact them to seek  permission.
    Search  for  Copyright and ownership and it should bring up some good information. Depending on your country.. it may have its own  Copyright website. USA are more detailed than most, The UK has the 1988 Copyright Act.
    Also remember that all photo images carry exif embedded data which  among other things carries the copyright information and shows up in a google search for the right  keyword!  Scanned images processed through Photoshop and other editors  can have the metatdata added also.

  • Opening an .xls file and writing data to it....

    Hi ,
    I have written the following simple routine... which is supposed to open a .xls file and some data are written...:
    DECLARE
    application ole2.obj_type;
    workbooks ole2.obj_type;
    workbook ole2.obj_type;
    worksheet ole2.obj_type;
    worksheets ole2.obj_type;
    cell ole2.obj_type;
    --Declare handles to OLE argument lists
    args ole2.list_type;
    BEGIN
    application:=OLE2.CREATE_OBJ('Excel.Application');
    OLE2.Set_Property(application,'Visible', 'True');
    workbooks := ole2.get_obj_property(application, 'Workbooks');
    workbook:=OLE2.INVOKE_OBJ(workbooks,'Add');
    args:= ole2.create_arglist;
    ole2.add_arg(args, 'c:\example.XLS');
    workbook := ole2.invoke_obj(workbook, 'Open', args);
    ole2.destroy_arglist(args);
    args:=OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 1); 
    OLE2.ADD_ARG(args, 1);
    cell:=OLE2.Invoke_Obj(workbooks, 'Cells', args); 
    OLE2.DESTROY_ARGLIST(args);
    OLE2.Set_Property(cell, 'Value', 'Excel');
    args := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args, 0);
    OLE2.INVOKE(workbook, 'Close', args);
    OLE2.DESTROY_ARGLIST(args);
    OLE2.RELEASE_OBJ(cell);
    OLE2.RELEASE_OBJ(workbook);
    OLE2.RELEASE_OBJ(workbooks);
    OLE2.RELEASE_OBJ(application);
    OLE2.INVOKE(application,'Quit');
    END; but it does nothing.... it simply opens the Excel application..... How should I modify the routine in order to open the example.xls file and write some data to it .....???????
    Many thanks,
    Simon

    OK... I SOLVED THE PROBLEM.....
    Regards,
    Simon

Maybe you are looking for