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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:12:36+00:00 2026-06-11T08:12:36+00:00

** FOR FUTURE READERS ** Although I accepted an answer, this problem is not

  • 0

** FOR FUTURE READERS **

Although I accepted an answer, this problem is not resolved for me. User dbf obviously knows his stuff and perhaps his answer will work for you. If it doesn’t, I apologize. The waters are too deep for me, and I’m out of time to spend on this, so I have reworked my code to remove the custom-file-input niceties. I’ll get my project completed and then, if possible, return to this code and post my solution. At the end of the day, however, user dbf put in a lot of effort and deserves the cred.


An ajax call returns a table structure, which gets placed inside form tags.

An ADD ROW button clones a table row, with a link (custom-file-input as anchor tag) for uploading a file.

I am replacing the INPUT TYPE=FILE element with the jquery-custom-file-input.js plugin, from here. This jquery plugin allows to turn any element into a file input element, so I am using an anchor tag #change_pd as the file input element. But to actually upload the file, the minimal documentation says to “attach the input element to a form element.”

This StackOverflow question addresses exactly this issue, but I haven’t been able to make it work in my case.

A standard submit button submits the form, where everything is received except the uploaded file.


HTML – An AJAX-generated table is inserted inside DIV #reportstable

<form action="" method="post" name="upd" enctype="multipart/form-data" id="AFrm">
    <div id="reportstable">
    </div>
</form>

AJAX – the returned table looks like this. The table is placed within div #reportstable, above.

<table id="DocTable">
<tr>
    <td>New Document</td>
    <td>
        <span id="span_pd"></span>
        <input type="hidden" id="proj_id" name="proj_id" value="'.$project_id.'">
        <input type="hidden" id="status_pd" name="status_pd">
    </td>
    <td>
        <a id="change_pd" href="#">change</a>
        <input type="hidden" id="new_pd" name="new_pd">
    </td>
</tr>
</table>

JQUERY – This is the code to insert a file. It does put the chosen filename into the SPAN as text, and into the hidden input file #new_pd, which is received in the $POST data.

However, the file itself is not uploaded.

I am not sure where to put the .appendTo(), or how to write the jquery. Here is what I tried. Everything works except the .appendTo().

$(document).on('click','#change_pd',function() {
    $(this).file().choose(function(e, input) {
        $('#new_pd').val(input.val());
        $('#span_pd').html(input.val());
        $('#span_pd').css('color','grey');
        $('#status_pd').val('CHANGED');
    });
    $(this).css('text-transform','uppercase');
    $(input).appendTo('#AFrm').
        attr('name', 'a-name').
        attr('id', 'an-id');
    });

PS – If anyone can recommend a better (preferred?) custom-file-input plugin, I’m all ears.

  • 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-11T08:12:38+00:00Added an answer on June 11, 2026 at 8:12 am

    If you look at the code from the plugin you gave

        var file = $('<div><form></form></div>').appendTo('body').css({
            'position': 'absolute',
            'overflow': 'hidden',
            '-moz-opacity': '0',
            'filter':  'alpha(opacity: 0)',
            'opacity': '0',
            'z-index': '2'      
        });
    
        var form = file.find('form');
        var input = form.find('input');
    
        function reset() {
            var input = $('<input type="file" multiple>').appendTo(form);
            input.change(function(e) {
                input.unbind();
                input.detach();
                btn.trigger('choose', [input]);
                reset();
            });
        };
        reset();
    

    then you will see that the <form> and <input type="file" multiple> are appended to the body. This means that your form with id="AFrm" will not contain any <input type="file"> element and that’s why you are not uploading any file but only receive the selected name of the file.

    You could adapt the plugin to append the input to a specific form given by a parameter as an option through an object like { 'form':$('#AFrm') }

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

Sidebar

Related Questions

(changed title so as not to confuse future readers) Is this an authoritative list
(Note to any future readers: The error, unsurprisingly, is in my code and not
Edit: FYI for future readers, this issue has been fixed as of version 2.3.606.0
EDIT: Dear Future Readers, the std::string had nothing to do with the problem. It
This class hangs at Future.get() method after executing ExecutorService.shutdownNow() called. I don't know what
In the interest of future readers and my own sanity later, I like to
This is a moot question as I'm not on this project any more, but
Update for future readers: When .NET 4 comes out, LazyInit<T> from the CTP will
I'm trying to make my code easily understood by future readers. I've always had
In the near future, my organisation will have to change both the machine name

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.