在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,页面已经做好了,现在就是和虚拟机里C代码的通信,socket编程还可以,就是拿数据的处理,难,。
类的编程我不会,没有学过C++。本来打算用结构体的,可是PHP里面居然没有结构体,怎么办呢?继续努力吧
......
<!-- xml格式
<foo xmlns="test">
<bar attr='a'></bar>
<bar attr='b'></bar>
<bar attr='c'></bar>
</foo>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('attr.xml'))
{
echo "load books.xml failed!<br>";
re ......
<!-- 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 ......
conn.php
<?php
/*
* Created on 2010-1-6
* Author:CHAUVET
* Function:连接字符串
*/
$conn=@mysql_connect("localhost","root","")or die("连接数据库出错!");
mysql_select_db("newdb",$conn);
mysql_query("set names 'gb2312'");
function ReplaceSom ......
delphi 编写的com 对象 用php调用
的
实例
delphi:
function Tmyxml.Get_xml: WideString;
begin
Get_xml:='wo shi a lei!';
end;
function Tmyxml.Get_xmldata: WideString;
var
xmlStr:string;
begin
xmlStr := '<?xml version="1.0" & ......