/
upload.php
118 lines (112 loc) · 3.71 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php require 'inc/config.php'; ?>
<?php
$include_mode="jquery-form";
$GETS_STRING="mode,filename";
$GETS=getGET_POST($GETS_STRING,'GET');
switch($GETS['mode'])
{
case 'upload':
@mkdir("upload",0777);
//pre_print_r($_FILES);
$ok_file = "doc,docx,ppt,pptx,pdf";
$m_ok_file = explode(',',$ok_file);
for($i=0,$max_i=count($_FILES['upfile']['name']);$i<$max_i;$i++)
{
$sn = strtolower(subname($_FILES['upfile']['name'][$i]));
if(!in_array($sn,$m_ok_file))
{
continue;
}
if($_FILES['upfile']['size'][$i]==0)
{
continue;
}
$nfilename=sprintf("%s_%s.%s",time(),$i,subname($_FILES['upfile']['name'][$i]));
copy($_FILES['upfile']['tmp_name'][$i],"{$base_dir}/upload/{$nfilename}");
$m=ARRAY();
$m['orin_filename']=$_FILES['upfile']['name'][$i];
$m['filename']=$nfilename;
$m['kind']=$sn;
$m['create_datetime']=date('Y-m-d H:i:s',filectime($_FILES['upfile']['tmp_name'][$i]));
$m['upload_datetime']=date('Y-m-d H:i:s');
$m['title']="";
$m['keyword']="";
$m['author']="";
switch($sn)
{
case 'pdf':
//如果傳的是pdf,就不用傳了
$m['pdf_status']="2";
break;
default:
$m['pdf_status']="0";
break;
}
$m['png_status']="0";
$m['text_status']="0";
$LAST_ID = insertSQL('ppt',$m);
switch($sn)
{
case 'pdf':
copy("{$base_dir}/upload/{$nfilename}","{$OUTPUT_PDF}/{$LAST_ID}.pdf");
break;
}
}
?>
<div style="background-color:pink;text-align:center;">
上傳成功<br>
</div>
<br>
<?php
location_replace("admin/maintain.php");
exit();
break;
}
?>
<?php require "{$base_dir}/template/html.php"; ?>
<?php require "{$base_dir}/template/head.php"; ?>
<script language="javascript">
function mySubmit(){
$('#theform').ajaxSubmit({
beforeSend: function () {
},
uploadProgress: function (event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
if($("#percent").size()!=0)
{
$("#percent").html(percentVal);
}
},
complete: function(xhr) {
alert("傳完了...");
dialogOff();
//location.reload();
location.href="<?=$base_url;?>/admin/maintain.php";
}
});
}
$(document).ready(function(){
$("#theform").submit(function(){
dialogOn("上傳中...<span id='percent'>0%</span>",false,function(){
mySubmit();
});
return false;
});
});
</script>
</head>
<?php require "{$base_dir}/template/body.php"; ?>
<?php require "{$base_dir}/template/top.php"; ?>
<!--start-->
<h2>各種簡報上傳</h2>
<fieldset style="width:50%;margin-left:auto;margin-right:auto;">
<legend>上傳檔案(可複選多個):(doc,docx,ppt,pptx,pdf...)</legend>
<form id='theform' action="?mode=upload" method="post" enctype="multipart/form-data">
上傳檔案:<input type="file" id="upfile" name="upfile[]" multiple="true">
<input id="submit_btn" type="submit" value="上傳">
</form>
</fieldset>
<!--end-->
<?php require "{$base_dir}/template/footer.php"; ?>
</body>
</html>