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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:34:59+00:00 2026-05-13T15:34:59+00:00

I came to see that form file input field value cannot be set with

  • 0

I came to see that form file input field value cannot be set with javascript for security reasons.

I just want to copy a FILE input to another form and post it, I searched for a work around and could not find anything, is it possible?

UPDATE: my code:

function prepareUpload( filevalue ){

document.getElementById('logo').value =filevalue;
var mform = document.getElementById('sleeker');
    ajaxUpload( mform,'<?php echo base_url(); ?>'); // a methods to upload...
}

<input class="input-file-upload" type="file" size="20" name="logodummy" id="logodummy" onchange="prepareUpload( this.value );" />

<form action="" method="post" name="sleeker" id="sleeker" enctype="multipart/form-data" onbeforesubmit="return false;">
            <p><input type="hidden" name="logo" id="logo" /></p>
        </form>

Anything other thatn file input are working fine, and I could receive with $_POST, but $_FILES doesn’t have values. And this code alone working fine too. I think this coe is enough?

  • 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-13T15:34:59+00:00Added an answer on May 13, 2026 at 3:34 pm

    Yes, you can place the <input type="file"> outside your HTML form, and then use the onChange event to fill an <input type="hidden"> within the form that gets posted:

    <input type="file" 
           onchange="document.getElementById('hidden_file').value = this.value;" />
    
    <form method="POST">
        <input type="hidden" id="hidden_file" value="" />
        <input type="submit" />
    </form>
    

    However in modern browsers, you will only be able to access the file name, and not the full path. You may want to check the following Stack Overflow posts for further information on this topic:

    • Can’t get the complete address while uploading a file
    • How to get the file path from HTML input form in Firefox 3

    UPDATE:

    The original question made me think that you only needed to copy the “file name” to another HTML form, and not the whole <input type="file"> representation.

    Further to the update, I assume you meant something like this:

    <input type="file" 
           onchange="document.getElementById('hidden_file').value = this.value;" />
    
    <form method="POST">
        <input type="file" id="hidden_file" value="" />
        <input type="submit" />
    </form>
    

    Unfortunately the above does not work. Firefox will return "Security error code: 1000" if you try the above example.

    As for some workarounds, you may want to the check David Dorward‘s suggestions:

    • Using cloneNode
    • Moving the input field with appendChild before submitting the form
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across a controller in an older set of code (Rails 1.2.3) that
This came up in Hidden features of Python , but I can't see good
I came up with a solution, but I wanted to see if anyone had
while exploring jQuery I came up with the following weird script. I don't see
I came across a printed article by Bertrand Meyer where he states that tests
Came across this error today. Wondering if anyone can tell me what it means:
I came across this article written by Andrei Alexandrescu and Petru Marginean many years
I came across this recently, up until now I have been happily overriding the
This came up from this answer to a previous question of mine . Is
I came aboard a new project with a new company and we are trying

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.