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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:14:25+00:00 2026-06-06T01:14:25+00:00

Let me know if anyone know what is the issue with this code. Basically

  • 0

Let me know if anyone know what is the issue with this code.

Basically i want to upload a file using jQuery

<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>

  <script type="text/javascript">
    $(document).ready(function(event) {
      $('#form1').submit(function(event) {
        event.preventDefault();
        $.post('post.php',function(data){
           $('#result').html(data);
        });
      });
    });
  </script>  
</head>
<body>
<form id="form1">
  <h3>Please input the XML:</h3>
  <input id="file" type="file" name="file" /><br/>
  <input id="submit" type="submit" value="Upload File"/>
</form>

<div id="result">call back result will appear here</div>

</body>
</html>

and my php ‘post.php’

<?php
  echo $file['tmp_name'];
?>

Uploaded File name is not returned back. Issue is i couldn’t access the uploaded file.

Thanks in advance!
Shiv

  • 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-06T01:14:27+00:00Added an answer on June 6, 2026 at 1:14 am

    Basically i want to upload a file using jQuery

    You cannot upload files using AJAX. You could use the jquery.form plugin which uses a hidden iframe:

    <html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="http://malsup.github.com/jquery.form.js"></script>
        <script type="text/javascript">
            $(document).ready(function(event) {
                $('#form1').ajaxForm(function(data) {
                    $('#result').html(data);
                });
            });
      </script>  
    </head>
    <body>
    <form id="form1" action="post.php" method="post" enctype="multipart/form-data">
        <h3>Please input the XML:</h3>
        <input id="file" type="file" name="file" /><br/>
        <input id="submit" type="submit" value="Upload File"/>
    </form>
    
    <div id="result">call back result will appear here</div>
    
    </body>
    </html>
    

    Also notice the enctype="multipart/form-data" on the form.

    Another possibility is to use the HTML5 File API which allows you to achieve that assuming the client browser supports it.

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

Sidebar

Related Questions

Can anyone let me know how to parallelize for loops using Java 5's JParallelLoops.jar
Can anyone let me know how to implement this feature specified at http://vimeo.com/24475654 Specially
Did anyone who used jQuery Easy Confirmation plugin run into this issue - the
Can anyone let me know how can access an element of a list that
Can anyone please let me know how to deterimine the number of address lines
Please let me know if I'm coming at this block on a wrong angle.
I am facing an issue with SecureRandom in java. This was the code that
I have this js code where I am using the Mapstraction library to show
I don't even know how to state this clearly, and there's too much code
There's code below, but this is also a conceptual issue. The question: Are the

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.