[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • 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 FiedererCommented:
You could use an INPUT tag with style="display:non", and have your function change style to "display:inline".
0
 
Jens FiedererCommented:
<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
Independent Software Vendors: 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!

 
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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