- function Upload($uploaddir)
- {
- $tmp_name =$_FILES['file']['tmp_name']; // 文件上传后得临时文件名
- $name =$_FILES['file']['name']; // 被上传文件的名称
- $size =$_FILES['file']['size']; // 被上传文件的大小
- $type =$_FILES['file']['type']; // 被上传文件的类型
- $dir = $uploaddir.date("Ym");
- @chmod($dir,0777);//赋予权限
- @is_dir($dir) or mkdir($dir,0777);
- //chmod($dir,0777);//赋予权限
- move_uploaded_file($_FILES['file']['tmp_name'],$dir."/".$name);
- $type = explode(".",$name);
- $type = @$type[1];
- $date = date("YmdHis");
- $rename = @rename($dir."/".$name,$dir."/".$date.".".$type);
- if($rename)
- {
- return $dir."/".$date.".".$type;
- }
- }
- 调用:
- $image = Upload('../images/photo/');
复制代码 |