2

我有以下代码用于在提交时上传图像的表单。在除 IE 之外的所有当前浏览器中都可以正常工作(没有版本工作):

$('#photo-upload').live('change', function()
{
$('#'+currentId+' > img').css('opacity',0);
$('#'+currentId).addClass('hasImg');
index = currentId.replace(/place-/i, "");
$('#photo-index').val( index );
$("#imageform").ajaxForm({ target: '#photo-'+index }).submit();

// initialize photo settings
photo_x_pos = 0;
photo_y_pos = 0;
photo_angle = 0;

});

和表单 HTML:

<form id="imageform" action="/orders/photo_upload" method="post">
    <div id="upload">
        <input type="file" name="data[Photo][image]" id="photo-upload" />
    </div>
    <input type="hidden" name="data[Photo][index]" id="photo-index" />
<input type="hidden" name="data[Photo][width]" id="photo-width" />
<input id="uploadthephoto" type="submit" value="Submit"/>
</form>

似乎 IE 中的问题是表单没有提交。#photo-upload是一个<input type="file"/>元素。#imageform是表单的id。所以理想情况下,当用户选择文件时,表单会提交目标#photo-0,并返回上传的图像。

难道我做错了什么?有没有其他方法可以提交不破坏 IE 的 ajaxForm?

4

0 回答 0