Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:43:50+00:00 2026-06-10T11:43:50+00:00

Im thy to upload file to server and send parametrs. But i have two

  • 0

Im thy to upload file to server and send parametrs. But i have two problems.

1 Cant send parametr. I do:

      handler: function(){
        mapinfo="mapinfo";
        formp.getForm().submit({
        url: url_servlet+'uploadfile',
        params: {file_type: mapinfo},
        success: function(formp, o) {
           alert(o.result.file);
           kad_tab.getStore().reload()
           zoom_store.load();
        }
    })
}

And server side:

public class uploadfile extends HttpServlet implements Servlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html");
    String st = request.getParameter("file_type");
    PrintWriter writer = response.getWriter();
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if (!isMultipart) {
            return;
        }          
  FileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);
    List<FileItem> list=null;
    String mifpath= "1";
    String path = " ";
    String mif = " ";
    String from = "\\\\";
    String to ="/";
    String error="";
     try{
      list = upload.parseRequest(request);
      Iterator<FileItem> it = list.iterator();
      response.setContentType("text/html");
      while ( it.hasNext() ) 
      {

        FileItem item = (FileItem) it.next();
        File disk = new File("C:/uploaded_files/"+item.getName());

            path = disk.toString();
            String code = new String(path.substring(path.lastIndexOf("."), path.length()).getBytes("ISO-8859-1"),"utf-8");
            if (code.equalsIgnoreCase(".zip"))
            {
                mifpath=path;
                mif = mifpath.replaceAll(from, to);
                item.write(disk);
                //error=unzip.unpack(mif, "C:/uploaded_files");
            }
            else
            {
                error = "Выбранный файл не является архивом zip";

            }
      }
    }

     catch ( Exception e ) {
      log( "Upload Error" , e);
    }
     System.out.println("st="+st);
    writer.println("{success:true, file:'"+error+"'}");
    writer.close();
}
}

But in console get only st=null.

2 Cant use combobox in fileuploadpanel:

var x = new Ext.Window({
                                title:'Загрузка файла',
                                items:[
                                    formp = new Ext.FormPanel({
                                        fileUpload: true,
                                        width: 350,
                                        autoHeight: true,
                                        bodyStyle: 'padding: 10px 10px 10px 10px;',
                                        labelWidth: 70,
                                        defaults: {
                                            anchor: '95%',
                                            allowBlank: false,
                                            msgTarget: 'side'
                                        },
                                        items:[{
                                    xtype:"combo",
                                    fieldLabel:'Тип файла ',
                                    name:"cb_file",
                                    id:"cb_file",
                                    mode:"local",
                                    typeAhead: false,
                                    loadingText: 'Загрузка...',
                                    store:new Ext.data.SimpleStore({
                                        fields: ['file_name', 'file_type'],
                                            data : [['*.MIF/MID', 'mif'],['*.GPX', 'gpx']]
                                        }),
                                    forceSelection:true,
                                    emptyText:'выбирите тип...',
                                    triggerAction:'all',
                                    valueField:'file_type',
                                    displayField:'file_name',
                                    anchor:'60%'
                                },{
                                            xtype: 'fileuploadfield',
                                            id: 'filedata',
                                            emptyText: 'Выберите файл для загрузки...',
                                            fieldLabel: 'Имя файла',
                                            buttonText: 'Обзор'
                                        }],
                                        buttons: [{
                                            text: 'Загрузить',
                                            handler: function(){
                                                mapinfo="mapinfo";
                                                    formp.getForm().submit({
                                                        url: url_servlet+'uploadfile',
                                                        params: {file_type: mapinfo},

                                                        success: function(formp, o) {

                                                            alert(o.result.file);


                                                            kad_tab.getStore().reload()
                                                            zoom_store.load();
                                                            }
                                                    })
                                            }
                                        }]
                                    })
                                ]   
                             })
                             x.show();

If i do this on server side nothing work. For example if i upload not a zip archive i gona get alert with words that its not zip file, but not get it. If i not add combobox on panel i get this alert. Whats wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:43:51+00:00Added an answer on June 10, 2026 at 11:43 am

    That´s because the request is a multipart one. Then, you can´t read params using:
    String st = request.getParameter(“file_type”);

    bacause it will always being null. Instead, use the following snipet:

    List items = upload.parseRequest(request);
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
    
        if (item.isFormField()) {
            processFormField(item);
        } else {
            processUploadedFile(item);
        }
    }
    

    About your second question, i couldn´t understand it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been trying to write an awk script which processes a log file, but
I have two pages one is step1.jsp, here the user can input its Function,
I have a menu (with ul and li) who call #anchors, thy are located
Basically i don't want to compare elements, but elements that thy contain. It would
I have the following function that is giving me variable declared and not used
I have 3 file as following : output-xml.php phpsqlajax_map.htm database.php In order to get
Simple question (probably), but I'm buggered if I can find an answer... I have
I have a Java function which can take variable number of parameters and in
I have a bunch of tick boxes that need to be inserted into one
i have relationship: // In A.java class @OneToMany(mappedBy=a, fetch=FetchType.LAZY) @Cascade(CascadeType.SAVE_UPDATE) private List<B> bList; //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.