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 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

Ask A Question

Stats

  • Questions 353k
  • Answers 353k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As I suspected in my original question, the issue is… May 14, 2026 at 7:49 am
  • Editorial Team
    Editorial Team added an answer looks to me like you should just change the order… May 14, 2026 at 7:49 am
  • Editorial Team
    Editorial Team added an answer No, but now they are the same private double memberVal;… May 14, 2026 at 7:49 am

Related Questions

I'm trying to use the Unix command paste, which is like a column-appending form
Ok, I need help. This is my first question here. Background: I am working
I have a layout of medium complexity based on several nested TableLayoutPanel s. Resizing
In one of my previous questions I explained about a form class that contain
Thanks for the responses.. i put a live version of the code.. to see

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.