|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
您现在的位置: ChinaBeta.cn 中文IT资讯 >> 网盟学院 >> 编程类 >> PHP >> 网管技术正文
推荐网管技术让我穿过那道"墙"! 畅游网络应…推荐网管技术主动防御!瑞星杀毒2008抢先评…
推荐网管技术速度超快 Discuz! 6.0.0试用手…推荐网管技术奇虎举证:各杀毒软件均报CNNIC…
推荐网管技术Google Earth 4.2加入繁体中文…推荐网管技术专业防护!瑞星防火墙2008测试…
推荐网管技术挂载RAR文件 从认识到爱上WinM…推荐网管技术让你冲浪随心所欲 如何访问被封…
推荐网管技术轻装上阵!江民杀毒软件2008速…推荐网管技术VMware Fusion苹果版全程图解(…
推荐网管技术VMware Fusion苹果版全程图解(…推荐网管技术从菜鸟出发!征服高清详细评测全…
推荐网管技术VS2008和ASP.NET 3.5使用之初体…推荐网管技术[多图]Ubuntu 7.04 初体验
推荐网管技术东风吹战鼓擂 下载软件你选谁?推荐网管技术若隐若现 Windows XP DirectX …
推荐网管技术GPRS上网全攻略推荐网管技术主流杀毒软件Vista兼容性横评
推荐网管技术基于IRF的网络管理和业务管理解…推荐网管技术83个美丽的Wordpress主题
推荐网管技术软交换网络中的关键路由技术详…推荐网管技术不只是换肤?Windows Mobile 6 …
推荐网管技术css教程–十步学会用css建站(全…推荐网管技术巧妙设置路由 预防网络频繁掉线
推荐网管技术打造网络管理七大绝技推荐网管技术CorelDRAW X3 Service Pack 2 …
推荐网管技术重温经典:回归 Live Messenger…推荐网管技术Oracle数据库补丁分类、安装及…
PHP多文件上传实例
Www.ChinaBeta.Cn 更新时间:2008-1-2 阅读次数:

【ChinaBeta.Cn 网盟学院】
<?

// 本例来自与ZEND网站,由HUNTE整理



// ASP-style tags are okay in PHP 3.0.4_and_above; some HTML editors recognize these tags



// File Upload Script for PHP/3 for Windows



// Released under the terms of the public GNU license

// Based upon code written by Rasmus Lerdorf

// Modified for Windows by Michael Grier

// E-mail: bigmike@bigmweb.com



// You need to write-enable a directory, named "upload", below the one you place this script

in

// On Windows NT, you can do this with a DOS program named CACLS

// Directions for this can be found at "http://www.bigmweb.com/home/cacls.html"







if($action1){ 字串6

// if files have been uploaded, process them



?>

<html>

<head>

<title>File Upload Results</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 字串1

</head>



<body bgcolor="#FFFFFF" text="#000000">

<p><font face="Arial, Helvetica, sans-serif"><font size="+1">File

Upload Results
</font>

字串8









<?

set_time_limit
(60);

// make reasonably sure the script does not time out on large files

$path1 = dirname($PATH_TRANSLATED)."/upload/";

//print $PATH_TRANSLATED;

//print $path1."

";

// assign our path in a form PHP for Windows understands



for($i=1;$i<3;$i++)

{

$temp1="file".$i;

$temp2="file".$i."_name";

$source=$$temp1;

$source_name=$$temp2;

// print $temp."=".$$temp."

";



//print $file1_name;

//print $file2_name;

//exit;



//*****************

//$source = $file1;

//$source_name = $file1_name;

print $source."

";

print $source_name;

//exit;

if(($source <> "none")&&($source <> ""))
字串5


{

// see if the file exists; non-existing file has name of "none"

if($error1 <> 1)

{

// no need to copy a file if directory not write-enabled

$dest = $path1.$source_name;

// append file name to our path



if(copy($source,$dest)){

// copy the file from the temp directory to the upload directory,_and_test for success

echo "$source has been uploaded

n";

$imagesize = getimagesize($dest);

switch($imagesize[2])

{

case 0:

echo "

Image is a unknown

";

unlink($dest);

exit;

case 1:

echo "

Image is a GIF

";

echo "$dest has a width of $imagesize[0]

";

echo "$dest has a height of $imagesize[1]

";

$newname = $path1;

$newname .=$i.time() . ".gif";

if(copy($dest,$newname))

{

echo "

GIF Rename Successful from $dest to $newname";

}else {

echo " 字串8

GIF Rename Unsuccessful";

}

unlink ($dest);

break;

case 2:

echo "

Image is a JPG

";

echo "$dest has a width of $imagesize[0]

";

echo "$dest has a height of $imagesize[1]

";

$newname = $path1;

$newname .=$i.time() . ".jpg";

if(copy($dest,$newname))

{

echo "

JPG Rename Successful from $dest to $newname";

}else {

echo "

JPG Rename Unsuccessful";

}

unlink ($dest);

break;

case 3:

echo "

Image is a PNG

";

echo "$dest has a width of $imagesize[0]

";

echo "$dest has a height of $imagesize[1]

";

$newname = $path1;

$newname .=time() . ".png";

if(copy($dest,$newname))

{

echo "

PNG Rename Successful from $dest to $newname";

}else {

echo "

PNG Rename Unsuccessful";

}

unlink ($dest);

break;
字串5


}

}else {

echo "Upload directory not write-enabledn";

// you need to write-enable the upload directory

$error1 = 1; // set flag

}

}

unlink($source);

// delete the file from the temp directory

}



?>

<image src="upload/<? print basename($newname)?>">

<?

} //end for

?>



<a href="fup.php">Back</a> 字串6

</font></p>

</body>

</html>



<?

}

else {



?>



<html>

<head>

字串4



<title>File Upload</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>



<body bgcolor="#FFFFFF" text="#000000">
字串7


<p><font face="Arial, Helvetica, sans-serif"><font size="+1">File

Upload</font>





If your browser is upload-enabled, you will see "Browse"

(Netscape, Internet Explorer)_or_". . ." (Opera) buttons below.

Use them to select file(s) to upload, then click the "Upload"

button. After the files have been uploaded, you will see a results screen.



<form method="post" enctype="multipart/form-data" action="fup.php">

<input type="hidden" name="MAX_FILE_SIZE" value="800000">

<input type="hidden" name="action1" value="1">

File 1: <input type="file" name="file1" size="30">



File 2: <input type="file" name="file2" size="30">







<input type="submit" value="Upload">

</form>

</font></p>

</body>

</html>



<?



}



?>
Google

(责任编辑:hahack)

发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
热门文章 相关报道
普通网管技术 [软件应用]凤凰涅槃 驱动精灵2008归来 (01-03)最新网管技术
普通网管技术 [ASP|ASP.NET]为ASP.NET MVC框架添加AJAX支持 (01-02)最新网管技术
普通网管技术 [JSP|JAVA]从Java到Ruby:献给引路人的策略 (01-02)最新网管技术
普通网管技术 [PHP]PHP多文件上传实例 (01-02)最新网管技术
普通网管技术 [其它编程程序]QQ 静态截图完善实现之改造 CRec… (01-02)最新网管技术
普通网管技术 [其它编程程序]C++运算符重载转换运算符 (01-02)最新网管技术
普通网管技术 [其它编程程序]详细解析C++编写的ATM自动取款机… (01-02)最新网管技术
普通网管技术 [其它编程程序]C++中用vectors改进内存的再分配 (01-02)最新网管技术
普通网管技术 [其它编程程序]C++中的虚函数((((virtual funct… (01-02)最新网管技术
普通网管技术 [其它编程程序]C++中用函数模板实现和优化抽象操… (01-02)最新网管技术
  • php.ini 配置文件中文解释

  • windowsxp和2000环境下的ph…

  • 动网PHP论坛安装步骤图解

  • PHP+MYSQL+Zend安装方法

  • 用PHP+MySQL搭建聊天室

  • 如何在Windows配置整合PHP和…

  • PHP比ASP优秀的七个理由 至…

  • 怎样才能成为PHP高手?学会…

  • 构建可配置PHP应用程序的正…

  • PHP对文本数据库的基本操作…

  •   网友评论内容:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    I D *
    邮 箱
    主 页
    评 分 1分 2分 3分 4分 5分
    评 论

    关于我们  中国·国家信息产业部{粤ICP备06006652号}{陇ICP备06002562号}
    版权所有:『AK网盟基地』站长:Hahack | QQ:80505955 | E-mail:Hahack@Gmail.com
    Copyright (C) 2005-2007  akhack.org|chinabeta.cn All Rights Reserved