CCCam
CCCam

Reputation: 85

file upload insert url images

Is it possible with jquery:

When i have a simple upload file

<input type="file" />

and a

<img src="http://www.my.com/images/myimage.png">

when I click on the image to use the url image as file to upload?

Any approaches?

Upvotes: 0

Views: 463

Answers (1)

Ali
Ali

Reputation: 12684

It can only be done through javascript, however most browsers won't let you due to security reasons. IE will though, dont know if all version will or not.

<img src="images/flake.gif" name="flake" onclick="openUploadFileDialogue();">
<script>
function openUploadFileDialogue(){
    var frm = document.form1.upload;
    if(document.all && document.getElementById){
        document.form1.upload.click();
    }
}
</script>

You COULD style your upload element with CSS to get the desired result depending on what the desired result is.

Upvotes: 3

Related Questions