-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimages.php
More file actions
42 lines (32 loc) · 917 Bytes
/
images.php
File metadata and controls
42 lines (32 loc) · 917 Bytes
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
<?php
/**
* Created by PhpStorm.
* User: longer
* Date: 2017/5/6
* Time: 19:21
*/
require './utils.php';
$time = time();
$filecount = $_POST['filecount']?(int)$_POST['filecount']:false;
if(!$filecount||$filecount<1){
die(toJsonString(-10,"缺少必须的字段"));
}
$base_path = './images/';
$target_path = '';
$image_url = '';
for($i = 0;$i<$filecount;$i++){
$filename = 'file'.$i;
$type = substr($_FILES[$filename]['type'],strpos($_FILES[$filename]['type'],"/")+1);
$target_path = $base_path.$time."_".$i.".".$type;
$move_result = move_uploaded_file($_FILES[$filename]['tmp_name'],$target_path);
if($move_result){
$image_url .=substr($target_path,1).",";
}else{
die(toJsonString(-6,'图片上传失败'));
}
}
$image_url = rtrim($image_url,',');
$data = array();
$data[] = array('url'=>$image_url);
die(toJsonString(0,'图片上传成功',$data));
?>