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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:13:50+00:00 2026-06-12T00:13:50+00:00

I’m attempting to build an extremely simple, but cross-browser compatible, asynchronous file uploader, as

  • 0

I’m attempting to build an extremely simple, but cross-browser compatible, asynchronous file uploader, as a jQuery plugin and I’m having a bit of trouble getting the file to upload.

This plugin is based on the principle of submitting the form with the file input through an iframe. Bellow is the plugin code:

(function( $ ) {
    $.fn.asyncFileUpload = function(options) {

        // Create some defaults, extending them with any options that were provided
        $.fn.asyncFileUpload.defaults = {
            action : "",
            onStart : function(){},
            onComplete : function(){}
        };

        var settings = typeof options != "undefined" ? $.extend($.fn.asyncFileUpload.defaults, options) : $.fn.asyncFileUpload.defaults;        

        return this.each(function(){

            var date = new Date(),
                form = $(this), 
                formID = form.attr("id"),               
                iframe = $(document.createElement("iframe")),
                iframeID = "iframe-"+date.getTime();    // generate a unique ID for every iframe created (one iframe is associated with a single HTML form)

            iframe.attr({"id":iframeID, "name":iframeID}).css("display","none").appendTo("body");
            form.attr({ "target" : iframeID, "action" : settings.action });

            form.on("submit", function(event){
                iframe.load(function(event){
                    alert("iframe loaded");
                });   
            });

        });
    };
})( jQuery );

The HTML:

<form id="image-upload-form" method="post" enctype="multipart/form-data">
     Browse: <input type="file" id="image-to-upload" style="margin-left:5px;" />
     <input type="hidden" name="tag" value="a file" />
     <input type="submit" value="submit" />
</form>

<script>
     $("#image-upload-form").asyncFileUpload({
          action : "uploadimage.php"
     });
</script>

And on the server side, I put together just a minor script to check what’s going on with the file:

<?php   
    echo "tag: ".$_POST["tag"]; echo "<br />";
    echo "error: ".$_FILES["image-to-upload"]["error"];
?>

And the result is that the file doesn’t upload, but the somehow the “tag” input value reaches the server script, because it’s returned (I’m testing this using Chrome’s code inspector -> Network).
I say that the file doesn’t get uploaded because the returned value of $_FILES["image-to-upload"]["error"] is empty and neither does Chrome’s progress bar appear, despite the fact that the files I’ve been trying to upload are rather big.

What is it that I’m doing wrong here?

  • 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-12T00:13:52+00:00Added an answer on June 12, 2026 at 12:13 am

    The file input doesn’t have a name attribute – this will cause it to not be submitted.

    Give your file input a name so it can be accessed in the $_FILES array in the script.

    <form id="image-upload-form" method="post" enctype="multipart/form-data">
    
         Browse: <input type="file" 
                        id="image-to-upload" 
                        style="margin-left:5px;" 
                        name="image-to-upload"/>
    
         <input type="hidden" name="tag" value="a file" />
         <input type="submit" value="submit" />
    </form>
    

    Further reading here: http://www.w3.org/TR/html401/interact/forms.html#control-name

    I can’t find a specific part of the spec that clarifies what happens when an input is submitted with no name, but atleast in the case of Firefox and file inputs it seems the data does not get sent.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.