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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:14:18+00:00 2026-05-27T07:14:18+00:00

Possible Duplicate: Ajax file upload Is it possible to write an ajax request with

  • 0

Possible Duplicate:
Ajax file upload

Is it possible to write an ajax request with JQuery that “submits” a form with a file field? I want to do it because in this way i can make the user upload a file without leaving the current page.

How should i write the $.ajax() call? and in particular how should i set into the ajax call the file field?

EDIT: I’d like to use only core JQuery functions, without plugins.

Thanks.

  • 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-05-27T07:14:19+00:00Added an answer on May 27, 2026 at 7:14 am

    To maintain compatibility with the widest range of browsers this needs to be done through a hidden iframe.

    Here is some sample code to demonstrate what I mean:

    <iframe name="my_iframe" id="my_iframe" style="display: none;"></iframe>
    
    <form action="/next_step.php" method="post" target="my_iframe" entype="multipart/form-data">
        <input type="file" name="file_upload" />
        <input type="button" id="upload_btn" value="Upload file" />
    
        <label for="name">Name</label>
        <input type="text" name="name" id="name" />
    
        <input type="submit" value="Next step" />
    </form>
    
    <script type="text/javascript">
        var btn = document.getElementById('upload_btn');
        btn.onclick = function(){
            var form_elem = document.forms[0];
            // direct file uploads through the hidden iframe
            form_elem.action = '/test_file.php';
            form_elem.target = 'my_iframe';
    
            // submit the form
            form_elem.submit();
        };
    </script>
    

    There are projects out there that make this easier such as Plupload

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

Sidebar

Related Questions

Possible Duplicate: How can I upload files asynchronously with JQuery? I have a file
Possible Duplicate: How to hide text field in Html File Upload I'm setting up
Possible Duplicate: jquery ajax call taking too long or something for some reason this
Possible Duplicate: jquery/ajax load new content when available i have a table named news
Possible Duplicate: jQuery: How to stop AJAX function escaping JSON string used to POST
Possible Duplicate: Kill Ajax requests using JavaScript using jQuery Here is the simple code
Possible Duplicate: jquery validate & ajax.beginform I'm trying to use the jQuery validate plugin
Possible Duplicate: E-mail validation in php? please help I have Ajax sign up form.
Possible Duplicate: jQuery ajax() vs get()/post() what is the difference between jQuery ajax() and
Possible Duplicate: How can I upload files asynchronously with JQuery? I'm submiting my forms

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.