0

I want to upload a image when click to a div, it ok in ff, chrome, safari but not working with IE, i don't know why? Please help me! Thanks.

This is my code:

<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $('#photo_box').click(function() {
                $('.upload_button').click();
            });

            $('input[name=f_img]').change(function(event) {
                $('#frm_upload').submit();
            });
        });
    </script>
</head>
<body>
<div style="width:100; height: 200px; border:1px solid red;" id="photo_box">Click here</div>
<form id="frm_upload" name="frm_img" method="post" enctype="multipart/form-data" style="position: absolute; left: -1000000px; top: -10100000px; opacity: 0;" target="ifr_img">
    <input type="file" class="upload_button" name="f_img"/>
</form>
<iframe id="ifr_img" name="ifr_img" style="width:200px; height:200px; border: 1px solid blue;"></iframe>
</body>

1 Answers1

0

As bobince explains here, it depends on the version and browser you are using and most versions of IE won't allow this (I'm not sure about IE9 though).

You could try the transparency technique or a Flash-based approach like Uploadify for jQuery.

Community
  • 1
  • 1
jmlnik
  • 2,867
  • 2
  • 17
  • 20
  • No, it not working after I choose a file in the files browse. The action 'change' of input file is working but the form is not submit? While don't have problem in ff, chrome and safari... – user1265546 Mar 13 '12 at 04:21
  • Yes @user1265546, that's what _bobince_ explains: "the form won't actually submit" – jmlnik Mar 13 '12 at 05:56