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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:53:41+00:00 2026-06-17T16:53:41+00:00

I have a HTML with a form in it like this: <html> <head> <script

  • 0

I have a HTML with a form in it like this:

<html>

<head>
  <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
</head>

<body>
  <form action="accept-file.php" method="post" enctype="multipart/form-data" id="theform">
    Your Photo: <input id="thefile" type="file" name="photo" size="25" />
    <input type="button" name="submit" value="Submit" onclick="submitform();"/>
  </form>
</body>

<script>

  function submitform()
  {
    data = $('*').serialize();

    $.post(
      'http://localhost/banksoal/1.0.0/accept-file.php',
      data
    );
  }

</script>

</html>

and the .php script like this:

        <?php
  //if they DID upload a file...
  if($_FILES['photo']['name'])
  {
    print_r($_FILES['photo']);
    $message = 'default message';

    //if no errors...
    if(!$_FILES['photo']['error'])
    {
      //now is the time to modify the future file name and validate the file
      $new_file_name = 'd:\\' . '--test-- '.basename($_FILES['photo']['name']); //rename file
      if($_FILES['photo']['size'] > (1024000)) //can't be larger than 1 MB
      {
        $valid_file = false;
        $message = 'Oops!  Your file\'s size is to large.';
      }
      else
      {
        $valid_file = true;
      }

      //if the file has passed the test
      if($valid_file)
      {
        //move it to where we want it to be
        move_uploaded_file($_FILES['photo']['tmp_name'], $new_file_name);
        $message = 'Congratulations!  Your file was accepted.';
      }
    }
    //if there is an error...
    else
    {
      //set that to be the returned message
      $message = 'Ooops!  Your upload triggered the following error:  '.$_FILES['photo']['error'];
    }
  }

  var_dump($message);
?>

The problem:
in the submitform() function, in the script tag at the line:

data = $('*').serialize();

why I get empty result?
What is wrong with the code?

Thank you

  • 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-17T16:53:42+00:00Added an answer on June 17, 2026 at 4:53 pm

    Give thsi a try as mentioned here: http://api.jquery.com/serialize/

    $('form').submit(function() {
      console.log($(this).serialize());
      return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this in my AJAX application: <html> <head> <script type=text/javascript> var
I have done something like this. <html> <head> <script type=text/javascript> <!-- function toggleTB(what){ if(what.checked){document.theForm.theTB.disabled=1}
I have a code like this. <html> <head> <title>Captcha With Refresh Feature</title> <script src=jquery.js
I have an HTML form that needs multiple submit buttons, like this: <input type=submit
I have a django template that looks like this: <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js type=text/javascript></script> <script
I have a webpage that looks like: <html> <head> <title>Hi</title> </head> <body> <form name=mainForm
I have a simple html form that is structured something like this: <form name=test
Okay so say I have a form element like this: HTML: <div class=form-item> <label>Current
I have a form in a .html files where input/select box looks like this
I have an ASP.NET MVC form laid out something like this: @using (Html.BeginForm(null, null,

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.