Solved

How do I put an image instead of the Browse button when using <INPUT type=file ?

Posted on 2001-07-25
10
183 Views
Last Modified: 2008-02-20
How do I put an image instead of the "Browse" button when using <INPUT type=file ... ?

or

 I tried to use the click method in order to open the "Browse" button on the <INPUT type=file ...> control. Well, it did open but when I tried to submit the form using either the submit() method or using <INPUT type=submit  ...> control I got a javascript error "Access denied".
How can I put a value in the <INPUT type=file ...> without having to manualy type in the path or manualy clicking on the "Browse" button ?
0
Comment
Question by:yohuy
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 19

Accepted Solution

by:
DreamMaster earned 75 total points
ID: 6321004
You can't...the problem with this <input type=file is that it is a control that allready has the browse button along with it...You cannot change it unless you customize all of it and that would be way too much work for what it actually does..

Cheers,
Max.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6321560
Any attempt to customize that I have seen actually change the browse button ends up with a non-functional browse button and in most cases the form is broken any way.

The browse button cannot be modified for security reason.  if it could be disquised, it would be a way for thieves to fool users into uploading files.

Cd&
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6321581
Exactly Cd&,

Security with these kinds of things is very strict, for the same reason it is not possible to select a file for it using scripting....as it would allow someone to auto send a file from your harddisk to their own...

Max.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:psogaa
ID: 6321726
You can hide the original input form with style...then the rest is up to javascript...something like this:

<html>
<head>
<title></title>
<script language="JavaScript">
function browse(){
  testForm.filetext.click();
  testForm.filetext2.value = testForm.filetext.value;
}
</script>
</head>
<body>
<form name=testForm>
  <input type=file name=filetext style="visibility:hidden"><br>
  <input type=text name=filetext2><a onclick="browse();">This could be an image</a>
</form>
</body>
</html>
0
 
LVL 2

Expert Comment

by:psogaa
ID: 6321734
bah, sorry...didn't read your question through :/ i guess you already tried that..
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6351887
yohuy,

The name of this site is experts-EXCHANGE because we exchange information.  You are serious about solving your problem, you need to participate by responing to the comments.  If you treat this like a new group, or the amateur forums, you will probably not get very good results.  We solve problems with dialog no one has posted in over a week because you have not responded, and it is not going to be taken seriously.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6537532
To close this out, I will be making a recommendation to CS
in about a week.  I would appreciate any comments from the
participants on how it should be disposed of.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6616352
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>

Points to DreamMaster
</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6616697
Comment from DreamMaster accepted as answer.

Thank you
Computer101
Community Support Moderator
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6618449
Thanks Computer101 :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question