Upload.class.php
1.08 KB
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
<?php
class Util_Utils_Upload
{
/**
* 判断文件是否是通过 HTTP POST 上传的
*
* @param string $tmp_name
* @return boolean
*/
public static function if_uploaded_file($tmp_name)
{
if (!$tmp_name || $tmp_name == 'none')
{
return false;
}
elseif (function_exists('is_uploaded_file') && !@is_uploaded_file($tmp_name) && !@is_uploaded_file(str_replace('\\\\', '\\', $tmp_name)))
{
return false;
}
else
{
return true;
}
}
/**
* 创建目录
*
* @param string $path
*/
public static function createFolder($path)
{
if (!is_dir($path))
{
upload::createFolder(dirname($path));
@mkdir($path);
@chmod($path,0777);
@fclose(@fopen($path.'/index.html','w'));
@chmod($path.'/index.html',0777);
}
}
/**
* 上传文件
*
* @param string $resourceFile
* @param string $destinationFile
* @return boolean
*/
public static function uploadFile($resourceFile, $destinationFile)
{
if (@copy($resourceFile, $destinationFile))
{
@unlink($resourceFile);
return true;
}
else
{
return false;
}
}
}
?>