Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Urgent: File Selector for image Uploading

Hi i have an image with a javascript function for the onClick event

what i want to do is to open up a file selector when the image is clicked can anyone help with this please;
0
Robinsonx6
Asked:
Robinsonx6
  • 3
  • 2
  • 2
1 Solution
 
Jens FiedererTest Developer/ValidatorCommented:
You could use an INPUT tag with style="display:non", and have your function change style to "display:inline".
0
 
Jens FiedererTest Developer/ValidatorCommented:
<INPUT type=file ....

of course.
0
 
Robinsonx6Author Commented:
how do i fire the inputs click event, from within my javascript function so it works in all browsers please?

Kind Regards
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
ZvonkoSystems architectCommented:
You need a fileUploadControl which is basicaly an form input field of type=file and you need to hide it. Then you call the fileUploadControl click()  event on Image onclick event.
Like this:

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>
<form name="myForm" enctype="multipart/form-data" method="post">
<input type="file" name="myFile" style="display:none;" onChange="document.getElementById('fName').innerHTML=this.value;this.form.Upload.style.display='';">
<span id="fName"></span>
<input type="submit" name="Upload" style="display:none;" value="Upload">
</form>
<img src="filesel.gif" onClick="document.forms[0].myFile.click()">
</body>
</html>


You see?

0
 
Robinsonx6Author Commented:
hi Zvonko, thanks for this but it only works in ie not firefox any ideas on how to get it working in FF aswell please
0
 
ZvonkoSystems architectCommented:
Sorry, it seams the FireFox is more restrictive with FileUpload features then IE.
A second observation that I had made with FileUpload is that as soon as you access by script any feature of the FileUpload object is the file not uploaded to server.
Sorry, but that all is security features of the browser.
I do not know how to upload a file by clicking on an image in FireFox.
By the way, calling click() of FileUploadControl does not throw an exception or error in FireFox. It simply does not do anything.
0
 
Robinsonx6Author Commented:
i hate coding for FF sometimes :-), thanks for your help
i will probably post this again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now