最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php ajaxfileupload实现ajax文件上传功能
时间:2022-06-24 17:32:22 编辑:袖梨 来源:一聚教程网
可以批量进行添加上传,简单方便
| 代码如下 | 复制代码 |
|
var str = ''; function ajaxFileUpload(){ $("#msg") .ajaxStart(function(){ $(this).show(); }); /* .ajaxComplete(function(){ $(this).hide(); }); */ $.ajaxFileUpload( { url:'up_deal.php', secureuri:false, fileElementId:'file1', dataType: 'text', //data:{name:'qinmi', id:'123'}, success: function(data){ if(data=='error'){ $('#msg').html("上传失败"); }else{ www.111com.net $('#msg').html("上传成功"); str += data+'@'; $('#fname').val(str); } } } ); return false; } |
|
up_deal.php
| 代码如下 | 复制代码 |
|
if ((($_FILES["file1"]["type"] == "image/gif") || ($_FILES["file1"]["type"] == "image/jpeg") || ($_FILES["file1"]["type"] == "image/bmp") || ($_FILES["file1"]["type"] == "image/pjpeg")) && ($_FILES["file1"]["size"] $extend = explode(".",$_FILES["file1"]["name"]); $key = count($extend)-1; $ext = ".".$extend[$key]; $newfile = time().$ext;
if(!file_exists('upload')){mkdir('upload');} move_uploaded_file($_FILES["file1"]["tmp_name"],"upload/" . $newfile); @unlink($_FILES['file1']); echo $newfile; }else { echo 'error'; } ?> |
|
其中需要用到ajaxfileupload.js 这个文件,
相关文章
- 绝区零V2.4版本般岳玩法攻略 06-30
- 红色沙漠竞技场摩斯肯怎么打 06-30
- FPV 无人机穿梭体育场航拍 06-30
- 《明日方舟终末地》将任意据点发展阶段提升至2级任务怎么做-怎样提升据点发展阶段 06-30
- 科幻海洋 溢出序列 06-30
- X 图标足球进球变装 06-30