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

  • SEARCH
  • Home
  • 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 9202517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:16:36+00:00 2026-06-17T23:16:36+00:00

I get the follwing exception when i try to upload a file in spring

  • 0

I get the follwing exception when i try to upload a file in spring :

The request sent by the client was syntactically incorrect.

this is how i submit the value through ajax :

function uploadComment(viewName,answers){
    var file_data = $("#CIMtrek_daily_originator_comments").val();
    alert("file_data "+file_data);
    $.ajax({
            type : "POST",
            url : "CIMtrek_Compliance_Daily_Shipments_FileUpload",
            data: {
                uploadFile : file_data,
                id : '0'
            },
        success: function (msg) {
            global.getElementById("CIMtrek_uploadedFileName").innerHTML=msg;
             alert("File Uploaded");
        }
    });

}

and this is my controller method :

@RequestMapping(value = "/CIMtrek_Compliance_Daily_Shipments_FileUpload", method = RequestMethod.POST)
    public String createComments(@RequestParam("uploadFile") MultipartFile  uploadItem ) {
        System.out.println(" CIMtrek_Compliance_Daily_Shipments_FileUpload : ");
        String uploadedFileName="";
        try {
            String fileName = null;
            InputStream inputStream = null;
            OutputStream outputStream = null;
            if (uploadItem.getSize() > 0) {
                inputStream = uploadItem.getInputStream();

                System.out.println("size::" + uploadItem.getSize());
                fileName = "/WEB-INF/resources/Attachment/"+ uploadItem.getOriginalFilename();

                outputStream = new FileOutputStream(fileName);
                System.out.println("fileName:" + uploadItem.getOriginalFilename());

                int readBytes = 0;
                byte[] buffer = new byte[10000];
                while ((readBytes = inputStream.read(buffer, 0, 10000)) != -1) {
                    outputStream.write(buffer, 0, readBytes);
                }
                outputStream.close();
                inputStream.close();
            }
            uploadedFileName =uploadItem.getOriginalFilename();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return uploadedFileName;
    } 

Please help me to resolve this.

  • 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-17T23:16:37+00:00Added an answer on June 17, 2026 at 11:16 pm

    You need to use serialize() instead of val() as below

    data: $(“#your_form”).serialize();

    $.ajax({
    type : "POST",
    contentType:false,
    url : "CIMtrek_Compliance_Daily_Shipments_FileUpload",
    data: $("#your_form").serialize(),
        success: function (msg) {
            global.getElementById("CIMtrek_uploadedFileName").innerHTML=msg;
             alert("File Uploaded");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following exception java.lang.NumberFormatException: Invalid int: It is happening when you try
I remove item from ArrayList in foreach loop and get follwing exception. Collection was
I get the following error: Unhandled Exception: System.IO.IOException: The parameter is incorrect. at System.IO.__Error.WinIOError(Int32
I'm trying to upload a file using JavaFX using the HttpRequest. For this purpose
Follwing exception is thrown when send https request from my webapp in tomcat server
I am trying to do a file upload from Silverlight(Client Object Model) to Sharepoint
Q: I get the following exception when i try to execute the following query:
I get the following exception when I try to send an email: Traceback (most
I get the following exception when i try to run the applet : java.lang.reflect.InvocationTargetException
I get the following exception when i try to run the applet : load:

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.