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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:38:55+00:00 2026-06-14T12:38:55+00:00

I have a file input that I have styled to be a custom button,

  • 0

I have a file input that I have styled to be a custom button, but i’m not able to keep the upload image when the user uploads the file. It is replaced with the text of the file name but i would also like to keep the image. I know it is something simple but can’t seem to figure it out. here is the code:

HTML:

 <div id="file"><img src="~/Images/choosefile.png" /></div>
 <input type="file" name="file"/>

Javascript:

var wrapper = $('<div/>').css({ height: 0, width: 0, 'overflow': 'hidden' });
var fileInput = $(':file').wrap(wrapper);

fileInput.change(function () {
    $this = $(this);
    $('#file').text($this.val().substring(12, 75));
})

$('#file').click(function () {
    fileInput.click();
}).show();

CSS:

`#file 
{
    display:none;
    cursor: pointer;
}​`

**Update – here is how it turned out if anyone would like to use it***

HTML:

 <div id="file" style="margin-right:10px;"><img src="~/Images/choosefile.png" style="margin-bottom:-5px; padding-right:10px;"/><span style="border-left-width:10px;"></span></div>
 <input type="file" name="file"/>

Javascript:

var wrapper = $('<div/>').css({ height: 0, width: 0, 'overflow': 'hidden' });
var fileInput = $(':file').wrap(wrapper);

fileInput.change(function () {
    $this = $(this);
    $('#file>span').text($this.val().substring(12, 75));
})

$('#file').click(function () {
    fileInput.click();
}).show();

CSS:

`#file 
{
    display:none;
    cursor: pointer;
}​`
  • 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-14T12:38:56+00:00Added an answer on June 14, 2026 at 12:38 pm

    When you use .text() it is replacing your image with the value of the file input. I recommended adding a span inside your DIV and setting the value of the current input on it. It will be easier to separate and keep track of.

    HTML

    <div id="file"><img src="~/Images/choosefile.png" /><span></span></div>
    <input type="file" name="file"/>
    

    JQuery

    var fileInput = $(':file').wrap(wrapper);
    fileInput.change(function () {
        $this = $(this);
        $('#file>span').text($this.val().substring(12, 75));
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a ASP.NET C# website I have an input that uploads a file to
I have a file upload button with a weird styling issue that I can't
I want to have an <input type='file'> that overlaps on an image, so that
Please help with the following: I have an input file that is quite heterogeneous
I have a program that reads input from a file. I am trying to
I have a php file that contains a form (which contains 2 input boxes
I have a perl program that takes input and output file arguments, and I'd
I have a linux utility that parses structured input ( a text file ),
I have this in my CSS file that styles input fields in a form:
I have a webpage that has 3 file inputs. There are specific fields on

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.