你要上多大的文件啊?
以前有过类似问题,结果有人说主要是浏览器的限制,
文件上传不能超过8M,也有人说不能超过10M,我这边测试7M多的是可以的。
如果使用FTP方式,据说需要客户端有PHP支持,这样倒不如使用FTP软件方便了
对这个问题目前还没有好的方案,如果你有解决的方法的话烦请告知。
[email protected]
以前有过类似问题,结果有人说主要是浏览器的限制,
文件上传不能超过8M,也有人说不能超过10M,我这边测试7M多的是可以的。
如果使用FTP方式,据说需要客户端有PHP支持,这样倒不如使用FTP软件方便了
对这个问题目前还没有好的方案,如果你有解决的方法的话烦请告知。
[email protected]
算了我还是麻烦一下贴过来给你好啦!
下面是我的解决办法你可以试一试!
##################test.php######################################
<html>
<body>
<form method="POST" action="../../cgi-bin/bupload.pl" ENCTYPE="multipart/form-data">
File 1:
<input type="file" name="FILE1">
<br>
File 2:
<input type="file" name="FILE2">
<br>
<input type="submit" value="Upload!">
</form>
</body>
</html>
####################bupload.pl#######################
#!c:/perl/bin/perl.exeuse CGI;
$upfilecount = 1;
$maxuploadcount = 2; #限制上传文件的最大数
$basedir = "../htdocs/upload/vod"; #上传的文件存放地址
$allowall = "no"; #是否不限制文件后缀上传
@theext =(".jpg",".bmp"); #要限制的文件后缀名#print "Content-type: text/html\n\n";$query=new CGI;
while ($upfilecount <= $maxuploadcount) {
my $req = new CGI;
my $file = $req->param("FILE$upfilecount");
if ($file ne "") {
my $fileName = $file;
$fileName =~ s/^.*(\\¦\/)//; #用正则表达式去除无用的路径名,得到文件名
my $newmain = $fileName;
my $filenotgood;
if ($allowall ne "yes") {
$extname = lc(substr($newmain,length($newmain) - 4,4)); #取后缀名
for(my $i = 0; $i < @theext; $i++){ #这段进行后缀名检测
if ($extname eq $theext[$i]){
$filenotgood = "yes";
last;
}
}
}
if ($filenotgood ne "yes") { #这段开始上传
open (OUTFILE, ">$basedir/$fileName");
binmode(OUTFILE); #务必全用二进制方式,这样就可以放心上传二进制文件了。而且文本文件也不会受干扰
while (my $bytesread = read($file, my $buffer, 1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);$new_url="../load/upload.php?name=$fileName";
$message.=$file . " 已成功上传!<br>\n";
}
else{
$message.=$file . " 文件后缀不符合要求,上传失败!<br>\n";
}
}
$upfilecount++;
}#print($new_url);
print $query->redirect($new_url); #最后输出上传信息
######################upload.php###########################
<?php
// get infomation file
$file=$name; // rename file
if ($file) {
$file_sub=strtok($file,".");
if ($file_sub) $file_sub=strtok(".");
$date=getdate();
$dest_filename="hztecklink-".$date["year"].$date["mon"].$date["mday"].$date["hours"].$date["minutes"].$date["seconds"].".".$file_sub;
$dest = "../upload/vod/".$dest_filename;
$target="../upload/vod/".$file;
if (!rename($target,$dest)) {
echo ("重命名失败!");
echo "<br>Target=",$target;
exit;
}
}header("location:test.php");
###############################################
注:上载的perl程序是由一个网友提供的。在此表示感谢!这个程序能上载好大的文件,我上载过的最大的文件是623M!