AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > PHP编程

让你同时上传 1000 个文件

51自学网 2015-09-11 http://www.wanshiok.com

2. 用 PERL 来保存:
它们实现的原理完全一样,在此不多说,请看代码:

fileup.cgi(fileup.pl)
----------------------------------------------------------------------
#!/usr/bin/perl

use CGI qw/:standard/;

if ($ENV{'CONTENT_TYPE'} !~ /multipart/form-data/) {
print "Cache-Control: no-cachenPragma: no-cachen" .
"Content-Type: text/htmlnn" .
"<html><body>Your web browser cannot upload files. Sorry.</body></html>";
exit 0;
}


$cntfile=param('cnt');
print header;
print start_html;
#print "Receiving Please wait....";

&g_head;

#$writed = '../www/test/tmp/';

for ($i=0;$i<$cntfile;$i++){
$paramfile = 'file'.$i;
$parampath='path'.$i;

$writed=param($parampath);

&upfile;
&g_body;
}

&g_bott;

#<<<<<<<<<<<<<<<<<<<<<以下为自定义过程<<<<<<<<<<<<<<<<<<<<<<<<<

sub upfile
{
$maxdata = 512000;
# $writed = '../www/test/tmp/';


$strRFname=reverse $xfile;
$intIndex=index($strRFname,'/');
$strNetFname=substr($strRFname,0,$intIndex);
$strNetFname=scalar reverse $strNetFname;


if((stat $xfile)[7]>$maxdata){
print "Status: 411 Size Not Allowedn" .
"Content-Type: text/htmlnAllow: POSTnn" .
"<html><head><title>411 411 Size Not Allowed</title></head><body><h1> You got big problem. Try again.</h1></body></html>n";
exit 0;
}


binmode $xfile;
use File::Copy;
copy($xfile,$writed.$strNetFname);
}

sub g_head{
print '<table border=1 align=center>';
print '<tr><td colspan=3 align=center>文件上传结果(Upload Result)</td></tr>';
print '<tr align=center>';
print ' <td>SourceFile:</td>';
print ' <td>DestFile:</td>';
print ' <td>Upload</td>';
print '</tr>';
}

sub g_body{
print '<tr>';
print ' <td>'.$xfile .'</td>';
print ' <td>'.$writed.$strNetFname.'</td>';
print ' <td>OK!</td>';
print '</tr>';
}

sub g_bott{
print '</table>';
}
----------------------------------------------------------------------

 

说明
:本教程来源互联网或网友上传或出版商,仅为学习研究或媒体推广,wanshiok.com不保证资料的完整性。
 

上一篇:PHP,&nbsp;JScript&nbsp;和&nbsp;VBScript&nbsp;函数和类的语法  下一篇:一个个人网页自动化生成系统