在php中将上传封装成类
在使用上传文件时,将上传的代码封装成类,更容易方便。
190.php
<?php
require('upload.php');
if($_POST['submit']){
$a = new Upload();
$File = $a -> uploadfile($ARG=array(
'File'=>array(
'name' => $_FILES['fileDoc']['name'], //原名字
'tmp_name' => $_FILES['fileDoc']['tmp_name'] //新名字
)));
}
echo $File['oldname'];
?>
<form action="<?echo $PHP_SELF?>" method="post" enctype="multipart/form-data">
<input type="file" name="fileDoc">
<br>
<input type="submit" name="submit" value="上传">
</form>
Upload.php
<?php
/**
* @author gb2312
* @since 2009-11-16
* @desc 文件上传
*/
class Upload{
/**
* @desc 文件上传方法
* @param Array $ARG 上传文件的属性
*/
public function uploadfile($ARG=array(
'File' => array(),
'Dir' => '')){
//默认目录
$dir = "upload/";
//文件原始名称
$oldname = $ARG['File']['name'];
//文件类型
 
相关文档:
解读PHP DOMDocument在解析XML文件中的作用
http://developer.51cto.com 2009-12-02 10:39 佚名 柳城博客 我要评论(0)
PHP DOMDocument的功能非常强大,我们在这篇文章中将介绍如何正确的运用PHP DOMDocument来进行XML文件的解析。希望对又需要的朋友有所帮助。
在使用PHP对XML文件进行解析的时 ......
PHP缓存代码
好的页面缓存代码,可以减轻CPU和MYSQL负担。使用前,先在根目录创建“cache”文件夹,然后运行1.php,第一次运行和第二次运行速度差异很大。欢迎熟悉PHP的朋友使用和提意见。
使用方法:(请保存为temp.php)
<?php
include('arrcache.php');
$cache = new ArrCache('cache',5,'txt');
......
最近发现很多网站都有一些圈人头像的功能,后来在网上GG了一下,发现是用OpenCV实现的,我也在内部服务器做了一下测试,如果可以实现,步骤如下:
一 安装
1、安装opencv
官方网站:http://www.opencv.org.cn (中文版)
具体安装方法可以参考官方网站:
http://www.opencv.org.cn/index.php/%E6%BA%90%E7%A0%81%E7% ......
<!-- xml 格式
<books>
<book id='1001'>
<author>andylin</author>
<title>c language</title>
<publisher id="aaa">O'Reilly</publisher>
</book>
<book id='1002'>
<author>congfeng</author>
<t ......
原帖地址:http://www.zedwood.com/article/126/php-mail-function-with-attachments
This code sends an html formatted email with attachments. This email sending script actually sends both a plaintext and an html body of the email, allowing the email client to choose which to display. The plaintext emai ......