AjaxUpload

ExpandedBlockStart.gif 代码
             < script >
                jQuery(
function (){                    
                    
var  upload  =   new  AjaxUpload(jQuery( ' #test4 ' ), {
                        action: 
' upload-test.php ' ,
                        name: 
' woohoo-custom-name ' ,
                        data: {
                            
' key1 ' " This data won't be sent, we will overwrite it. "
                        },
                        autoSubmit: 
false ,
                        responseType: 
' json ' ,
                        onChange: 
function (file, ext){
                        },
                        onSubmit: 
function (file, ext){
                            
//  Allow only images. You should add security check on the server-side.
                             if  (ext  &&   / ^(jpg|png|jpeg|gif)$ / i.test(ext)) {                            
                                
this .setData({
                                    
' key1 ' ' This should be alerted ' ,
                                    
' key2 ' ' ... '
                                });
                            } 
else  {
                                alert(
' not image ' );
                                
return   false ;
                            }                            
                        },
                        onComplete: 
function (file, response){
                            
this .disable();
                            alert(response.post.key1);
                        }
                    });
                    jQuery(
' #test4upload ' ).click( function (){
                        upload.submit();
                        upload.enable();
                        
return   false ;
                    });
                });                    
            
< / script>

 

 


这样就可以看到选择的文件了。 

    <div style="position:relative;">  
    <input id="fuploadImportExcel" name="fuploadImportExcel" size="30" type="file"  /> 
    <span id="SelectFile" style="position:absolute; top:2px; left:5px; line-height:20px;"></span>
    </div>

 

onChange: function(file,ext) { 

 $("#SelectFile").html(file);

 }, 

 

注: 默认的必须有文件才可以提交。如果文件是选填,则用户没选择文件就不可以提交。 我更新了一下ajaxupload.js

 代码

 

 

 /Files/myx/js/ajaxupload.rar

转载于:https://www.cnblogs.com/myx/archive/2010/05/11/1732767.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值