?
Solved

Urgent: File Selector for image Uploading

Posted on 2006-06-30
7
Medium Priority
?
248 Views
Last Modified: 2008-02-26
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
Comment
Question by:Robinsonx6
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 17017784
You could use an INPUT tag with style="display:non", and have your function change style to "display:inline".
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 17017797
<INPUT type=file ....

of course.
0
 
LVL 2

Author Comment

by:Robinsonx6
ID: 17017835
how do i fire the inputs click event, from within my javascript function so it works in all browsers please?

Kind Regards
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 17017957
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
 
LVL 2

Author Comment

by:Robinsonx6
ID: 17029903
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 17029920
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
 
LVL 2

Author Comment

by:Robinsonx6
ID: 17029931
i hate coding for FF sometimes :-), thanks for your help
i will probably post this again
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

650 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