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 9058945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:51:06+00:00 2026-06-16T14:51:06+00:00

Using XMLHttpRequest Level 2 I want to upload a File. I am using jQuery

  • 0

Using XMLHttpRequest Level 2 I want to upload a File.
I am using jQuery so I want to do it using jQuery in preference.

So I wrote the following code (coffescript, but should be easily readable by anyone familiar with javascript)

fileToUpload = event.currentTarget.files[0]

data = new FormData()
data.append("uploadedfile", fileToUpload) 

$.ajax({
    type: 'POST',
    url: url,
    data: data,
    contentType: false,
    processData: false,
    mimeType: 'multipart/form-data',
})

Using that code, on the server side with PHP I do a `

With Firefox 17.0.1 I get nothing. $_FILES is null, With Chromium 22.0 I get the the uploaded file (in a strange format, but at least something)

Array
(
    [uploadedfile] => Array
        (
            [name] => filename.txt
            [type] => application/octet-stream
            [tmp_name] => /tmp/phpWwenhc
            [error] => 0
            [size] => 189
        )

)

Does anyone knows if it is a Firefox bug? Is there a workaround? Am I doing something wrong?
I searched for a similar problem, but all suggested answers that I found didn’t work with me (were not for Firefox, were not using xhr level 2, etc)

Thanks in advance.

PLEASE: I don’t care about IE or older versions. Neither iframes solutions nor plugins. Just XmlHttpRequest Level 2. For those who didn’t heard about it take a look at: https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/FormData/Using_FormData_Objects

  • 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-16T14:51:08+00:00Added an answer on June 16, 2026 at 2:51 pm

    Remove the mimeType parameter, the browser will generate the correct mime type with the required boundry.

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

Sidebar

Related Questions

I am trying to upload an image to server using using XMLHttpRequest but fails.
I am wondering how to get the progress of a file upload using XMLHTTPRequest.
I'm trying to upload file, using XMLHTTPRequest, and sending this headers: Content-Type:multipart/form-data, boundary=xxxxxxxxx --xxxxxxxxx
I am using XMLHttpRequest to send a file from javascript code to a django
currently i using this code in phonegap application var xmlhttp = new XMLHttpRequest(); xmlhttp.open(GET,http://192.168.1.19:8080/searchMobile?categoryRequest=true,
I am using XMLHttpRequest responseText to GET a server txt file and load the
I'm using XMLHttpRequest, and I want to access a local variable in the success
Why was it decided that using XMLHTTPRequest for doing XML calls should not do
(This question is similar to this one , but it's for using XMLHttpRequest instead
I am using struts2 and jquery I am making a server request using XMLHttpRequest

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.