zoukankan      html  css  js  c++  java
  • uploadfiy 3.0

    uploadfiy v3.0中按钮可以轻易修改成中英文,而不至于想2.xx版本中,需要对中文进行编码。

    3.0中圆圆的按钮,很漂亮。

    但是,3.0中去掉了原来的onComplete函数,并且也去掉了从服务器端返回的response

    				$("#bibtext_upload").uploadify({
    					swf		:'images/uploadify.swf',
    					uploader	:'callback/uploadify.php',
    					fileTypeDesc	:'选择文件',
    					fileTypeExts	:'*.bib',
    					formData	:{'folder' : '/bibtext'},//自定义保存路径
    					auto            : true,
    					buttonCursor    : 'hand',
    					buttonText      : 'BIBTEXT', 
    					fileSizeLimit   : '10MB',
    					height          : 20,
    					width           : 100, 
    					multi           : true,
    					hideButton	: true,
        					wmode		: 'transparent',
    					onUploadComplete:function(file) {
    						 //alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate  + ' - 文件状态: ' + file.filestatus);
    						 
    					},
    					onUploadError	:function(file,errorString){
    						alert( 'id: ' + file.id + ' - 索引: ' + file.index  + ' - 文件名: ' + file.name  + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus + ' - 错误代码: ' + errorCode + ' - 错误描述: ' + errorMsg + ' - 简要错误描述: ' + errorString);
    					},
    					onUploadSuccess : function(file,data,response) {//上传完成时触发(每个文件触发一次)
    						alert('The file was saved to: ' + data);
    						//alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus + ' - 服务器端消息: ' + data + ' - 是否上传成功: ' + response);
    					}
    				});
    
    
    
    
    
    


    服务器端:
    <?php
    //使用uuid进行重名文件
    if (!empty($_FILES)) {
    	$tempFile = $_FILES['Filedata']['tmp_name'];
    	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    	$new_file_name = new_name( $_FILES['Filedata']['name']);
    	$targetFile =  str_replace('//','/',$targetPath) . $new_file_name;
    	move_uploaded_file($tempFile,iconv("UTF-8","gb2312", $targetFile));
    	echo $targetFile;//返回文件路径
    }
    
    /*重命名文件*/
     function new_name($filename){
    	$ext = pathinfo($filename);
    	$ext = $ext['extension'];
    	$name = basename($filename,$ext); 
    	$name = gen_uuid().'.'.$ext;
    	return $name;
     }
    function gen_uuid() {
        return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            // 32 bits for "time_low"
            mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
    
            // 16 bits for "time_mid"
            mt_rand( 0, 0xffff ),
    
            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand( 0, 0x0fff ) | 0x4000,
    
            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand( 0, 0x3fff ) | 0x8000,
    
            // 48 bits for "node"
            mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
        );
    }
    ?>



  • 相关阅读:
    ubuntu 安装 redis desktop manager
    ubuntu 升级内核
    Ubuntu 内核升级,导致无法正常启动
    spring mvc 上传文件,但是接收到文件后发现文件变大,且文件打不开(multipartfile)
    angular5 open modal
    POJ 1426 Find the Multiple(二维DP)
    POJ 3093 Margritas
    POJ 3260 The Fewest Coins
    POJ 1837 Balance(二维DP)
    POJ 1337 A Lazy Worker
  • 原文地址:https://www.cnblogs.com/james1207/p/3253838.html
Copyright © 2011-2022 走看看