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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:04:24+00:00 2026-05-16T08:04:24+00:00

I have been battling with this piece of code for literally days now… Would

  • 0

I have been battling with this piece
of code for literally days now…
Would appreciate any help

The script calls the php file without
a problem when the submit key is hit.
However, it doesnt post the form data
with it.

The HTML form

<form id="image_form" name="image_form" method="POST"

action=””
enctype=”multipart/form-data”>
File:

The Javascipt

$(function() {
$(".submit").click(function() {
  var obj = document.getElementById("form_div");
  var load = document.getElementById("load");
   jQuery.ajax({
    type: "POST",
    name: "image",
    url: "upload_imagel.php",
    enctype: "multipart/form-data",
    beforeSend: function(){
     obj.style.display = 'none';
     load.innerHTML = "<img src='../images/misc/ajax-loader.gif'

/>”;
},
error: function(){
alert(‘Error has occured’);
},
timeout:5000,
success: function( results ){
load.style.display = ‘none’;
obj.style.display = ‘block’;
}
})
return false;
});
});

The PHP

The following is then empty

$image=$_FILES['image']['name'];

Thanks to pekka I changed the following AJAX to

$(document).ready(function() { 
    var obj = document.getElementById("form_div");
    var load = document.getElementById("load");

    var options = { 
        beforeSend: function(){
             obj.style.display = 'none';
             load.innerHTML = "<img src='../images/misc/ajax-loader.gif' />";
            },
        success: function(){
             load.style.display = 'none';
             obj.style.display = 'block';
            },
        type:      'POST', 
        timeout:   5000 
    }; 

    $('#image_form').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
}); 

However still getting the same problem

$image=$_FILES['image']['name'];

Still empty 🙁

P.s. html form heading is now

<form id="image_form" method="POST" action="sMain/upload_image_small.php" enctype="multipart/form-data">

Am I missing something?

  • 1 1 Answer
  • 2 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-05-16T08:04:26+00:00Added an answer on May 16, 2026 at 8:04 am

    It’s not possible to do file uploads using AJAX, because your script will not get read access to a file on the client machine.

    You could take a look at the jQuery form plugin that uses an invisible iframe to achieve this.

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

Sidebar

Related Questions

I have been battling with this for a while, so any help would be
I've been battling with this issue for a couple of days now. I have
I have been battling this issue for a few days now and think I
So I have been trying and battling with this for a few hours now.
So I have been battling this issue for awhile now and tried many different
I've been battling this one for a while now. I have a stored proc
Have been stuck with this issue for a few days now, and really need,
I've been battling with this issue for over 2 weeks now and have gotten
Hey I have been battling with this problem for a while now. Perhaps there
I have been battling with this code for quite a while and just don't

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.