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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:55:02+00:00 2026-06-11T19:55:02+00:00

I have created FormData() that work very well, because i test it using jQuery.ajax.

  • 0

I have created FormData() that work very well, because i test it using jQuery.ajax.
but cause i want to have progress bar for uploading, i could not create it when i use jQuery.ajax . so i decided to use ajax directly and post form data. but getting form data using php is not work.

javascript

xhr.open("POST","assets/php/upload.php?action=uploadFiles");
xhr.setRequestHeader('Cache-Control', 'no-cache');
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'multipart/form-data');
xhr.send(newFormData);

php

print_r($_FILES); //output, empty array

This is my question, why cannot i get form data using php?

EDIT::

this is my try to make progress bar using jquery but it did not work very well. the progress bar will be complete very fast and the file is not uploaded yet.

function updateProgress(evt)
{
    // evt is an ProgressEvent.
    if (evt.lengthComputable)
    {
        var percentLoaded = Math.round((evt.loaded / evt.total) * 100);
        // Increase the progress bar length.
        $(".progress > div").css(
        {
            width: percentLoaded + '%'
        });

    }
}

$.ajax(
{
    url: 'assets/php/upload.php?action=uploadFiles',
    type: 'POST',
    data: newFormData,
    cache: false,
    xhr: function ()
    {
        myXhr = $.ajaxSettings.xhr();
        if (myXhr.upload)
        {
            myXhr.upload.addEventListener('progress', updateProgress, false);
        }
        return myXhr;
    },
    contentType: false,
    processData: false,
});

EDIT::

I finally found why i cannot get ajax request using $_FILES. that occurred because i set content type, now if i remove it from request, i can get ajax request. but now the progress bar will be complete soon while uploading file has not finished yet. where is the problem with my code?

thank you,
Alireza

  • 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-11T19:55:03+00:00Added an answer on June 11, 2026 at 7:55 pm

    Check HTML5-powered Ajax file uploads and this project: HTML5 AJAX File Uploader.

    This file provides a JavaScript object to simplify utilization of the HTML5 File API for AJAX uploading.

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

Sidebar

Related Questions

I have a pretty basic jQuery ajax thing happening, but I want to mix
I have created some JQuery that will expand a div 'popup' on hover and
I have created an android application that calls (using kSOAP library) a SOAP based
I have created a function that shows/hides different messages according to a combination of
I have created a dialog and got a problem that only part of the
i have created a photography website with an admin page that uploads photos to
I have created http service on android. And now I want to upload the
I have troubles with Drupal 7 and file uploading. My code that doesn't work:
I want to send multipart form in my android app but without using org.apache.http.entity.mime
Let me know if you want more details but: I have an different number

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.