Ajax file upload, $_FILES empty

I’m trying to access a uploaded file that gets posted with AJAX but my $_FILES array is empty.
I can still access everything in my $_POST array.

I’ve seen a bunch of posts regarding similar issues but none of the fixes seemed to work.
I’ve done this multiple times before with no problems and i can’t see what could be wrong here.

Here is my HTML form

<form enctype="multipart/form-data" action="include/ajaxCall.inc.php" class="postForm d-flex flex-column" method="post" id="createProduct">
        <input id="createProductImg" type="file" name="post_img" required><br>
        <input id="createProductName" type="text" name="post_name" placeholder="name" required>
        <input id="createProductPrice" type="text" name="post_price" placeholder="price" required>
        <input id="createProductManufactur" type="text" name="post_manufactur" placeholder="manufactur">
        <select id="createProductType" name="post_type"  required>
        <select id="clothingsex" name="clothingsex" required>
        <option value="unisex">Unisex</option>
        <option value="male">Male</option>
        <option value="female">Female</option>
        <textarea id="createProductDescription" name="post_description" required style="resize: none; placeholder="Write your description here:"></textarea>
        <input type="submit">

and here is my ajax

 $("#createProduct").submit(function(event) {
            var form = $(this);
            var url = form.attr('action');
                type: "POST",
                url: url,
                data: form.serialize() + "&addProduct=1",
                success: function(data) {

and her is the file that i send the POST to

if (isset($_POST['addProduct'])) {
        echo var_dump($_FILES);

221 thoughts on “Ajax file upload, $_FILES empty”

  1. Thank you for sharing superb informations. Your site is so cool. I’m impressed by the details that you have on this website. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for more articles. You, my friend, ROCK! I found simply the info I already searched all over the place and simply couldn’t come across. What a great web site.

  2. hello my lovely stopforumspam member

    What are the Types of Loans in Ohio depending on the purpose
    Specific purpose payday loans in Ohio. Funds received in debt may be spent only for a specific purpose specified in the loan agreement.
    Non-purpose loan. The debtor may spend the money received at his discretion.
    Most popular specific purpose payday loans in Ohio are:

    House loan. The most common, of course, is a mortgage when the purchased property acts as collateral for a loan. Sometimes a youth loan is issued, with lighter conditions for debtors. Still quite common is a housing loan that does not imply purchased housing in the form of collateral.
    Car loan – payday loans in Ohio to a car or similar vehicle. The key is often the purchased goods, making the terms of the loan better. Also, loan conditions are improved: car insurance, life and health insurance of the borrower, and receiving a salary to the account of the creditor bank.
    Land loan. To purchase a plot for construction or agricultural activities.
    Consumer. For purchases in modern supermarkets, equipment stores, you can take a personal loan right at the point of sale. Often, specialists located there can contact the bank and get a regular or fast payday loans. Borrowed funds automatically pay for the goods, and the consultant explains when and how to re-pay the debt.
    Educational loan. It is issued to students, as well as to applicants who have passed the competition, to pay for tuition at universities, colleges, etc.
    Broker loan. For the circulation of securities, payday loans in Ohio are issued to an exchange broker, se-curities are purchased securities.
    Others. Objectives not related to those listed, but agreed and approved by the creditor.

  3. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  4. I am not certain the place you are getting your info, however good topic. I must spend a while studying more or working out more. Thanks for magnificent information I used to be searching for this information for my mission.


Leave a Comment