我使用了本地上传程序,效果很好。尝试添加以下JS片段:
jQuery(\'#upload_image_button\').click(function() {
formfield = jQuery(\'#fwpPhoto\').attr(\'name\');
tb_show(\'\', \'media-upload.php?type=image&TB_iframe=true\');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery(\'img\',html).attr(\'src\');
jQuery(\'#fwpPhoto\').val(imgurl);
tb_remove();
}
然后,在HTML中:
<input id="fwpPhoto" name="facultyPhoto" value="">
<input id="upload_image_button" type="button" value="Upload Image">
用于多个上载程序
<input id="facultyPhoto-1" name="facultyPhoto-1" value="" class="fwpPhoto">
<input id="upload_image_button-1" class="uploadButton" type="button" value="Upload Image">
<input id="facultyPhoto-2" name="facultyPhoto-2" value="" class="fwpPhoto">
<input id="upload_image_button-2" class="uploadButton" type="button" value="Upload Image">
<input id="facultyPhoto-3" name="facultyPhoto-3" value="" class="fwpPhoto">
<input id="upload_image_button-3" class="uploadButton" type="button" value="Upload Image">
<input id="facultyPhoto-4" name="facultyPhoto-4" value="" class="fwpPhoto">
<input id="upload_image_button-4" class="uploadButton" type="button" value="Upload Image">
<script type="text/javascript">
jQuery(document).ready(function($){
var target = \'\';
$(\'.fwpPhoto\').each(function(index) {
var field = index + 1; //because index starts at 0
jQuery(\'#upload_image_button-\'+field).click(function() {
formfield = jQuery(\'#facultyPhoto-\'+field).attr(\'name\');
target = \'#\'+formfield;
tb_show(\'\', \'media-upload.php? type=image&TB_iframe=true\');
return false;
});
});
window.send_to_editor = function(html) {
imgurl = jQuery(\'img\',html).attr(\'src\');
jQuery(target).val(imgurl);
tb_remove();
}
});
</script>