高分求一个上传文件的php代码!谢谢!!! $file是一个数组的,print_r($file); 看看这个数组的结构,你就明白了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 正好,借你的帖子请人帮我改程序,哪里错了帮我改改,我看不出来************************************upload.php3<html><head><title>Upload Your File</title></head><body><form acction ="receiver.php3" enctype="multipart/form-data" METHOD=POST><input type ="hidden" name="MAX_FILE_SIZE" value="2000000"><input type ="file" name="uploadfile" size="32" maxlength="80"><input type="submit" value="Upload File!" name="sendit"><input type="submit" value="cancel" name="cancelit"><br></form></body></html> /*receiver.php3*/<?function do_upload(){global $uploadfile, $uploadfile_size;global $local_file,$error_msg;if($uploadfile=="none"){$error_msg="对不起,你没有选定任何文件上传!";return;}if($uploadfile_size >2000000){$error_msg="对不起,你要上传的文件太大了";return;}$the_time=time();$upload_dir="c:/web/upload";$local_file="$upload_dir/$the_time";if(file_exits('$local_file')){$seq=1;while(file_exits("$upload_dir/$the_time$seq")){$seq++;}$local_file="$upload_dir/$the_time$seq";};rename($uploadfile,$local_file);display_page();}display_page();function display_page(){ //这是你的页面内容}?><html><head><title>php3 receiving script</title></head><body><?if ($error_msg){echo "<b>$error_msg</b><br><br>";}if($sendit){do_upload();echo "文件上传成功!";elseif($cancelit){ Header("Location:$some_other_script");echo "文件上载失败!";exit;}else{some_other_func();}?></body></html> 我这里有个小程序,可以运行的 ,PHP手册上下的/*test.php*/<form enctype="multipart/form-data" action="save.php" method="POST"><input type="hidden" name="MAX_FILE_SIZE" value="30000">Send this file: <input name="userfile" type="file"><input type="submit" value="Send File"></form>/*save.php*/<?php// 在 4.1.0 以前的 PHP 中,需要用 $HTTP_POST_FILES 代替 $_FILES。// 在 4.0.3 以前的 PHP 中,需要用 copy() 和 is_uploaded_file() 来代替 move_uploaded_file()。$uploaddir = '/var/www/uploads/';$uploadfile = $uploaddir. $_FILES['userfile']['name'];print "<pre>";if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) { print "File is valid, and was successfully uploaded. Here's some more debugging info:\n"; print_r($_FILES);} else { print "Possible file upload attack! Here's some debugging info:\n"; print_r($_FILES);}print "</pre>";?>你看下你的PHP版本是多少的 这个问题网上有很多的。本站的FAQ里面phpx的精华里面自己去找一下吧!!! http://www.phpx.com/happy/brd4.html精华里面 用 remove_upload_filecopy 可能会有权限问题 获取mysql图片路径显示到网页 php数字循环,一直循环下去 远程取文件函数不知如何调用 数据库SQL语句 单引号 双引号 怎么用 请大家帮忙解决 绕开url跳转的问题 php翻页问题等待解答 好久没有那么热心帮助的人了,请 Meteorlet和 klend(苯鸟)再来接分 两个表查询的SQL这么写? php中ajax异步验证用户名是否重复出大事了,帮帮忙啊~~ 为什么有的系统中不直接输出HTML 而是通过调用JS输出,有什么好处么? 到底PHP手册是哪一本啊?在线等!!!
************************************
upload.php3
<html>
<head>
<title>
Upload Your File</title>
</head>
<body>
<form acction ="receiver.php3" enctype="multipart/form-data" METHOD=POST>
<input type ="hidden" name="MAX_FILE_SIZE" value="2000000">
<input type ="file" name="uploadfile" size="32" maxlength="80">
<input type="submit" value="Upload File!" name="sendit">
<input type="submit" value="cancel" name="cancelit"><br>
</form>
</body>
</html>
/*receiver.php3*/
<?
function do_upload()
{
global $uploadfile, $uploadfile_size;
global $local_file,$error_msg;
if($uploadfile=="none")
{
$error_msg="对不起,你没有选定任何文件上传!";
return;
}
if($uploadfile_size >2000000)
{
$error_msg="对不起,你要上传的文件太大了";
return;
}
$the_time=time();
$upload_dir="c:/web/upload";
$local_file="$upload_dir/$the_time";
if(file_exits('$local_file'))
{
$seq=1;
while(file_exits("$upload_dir/$the_time$seq"))
{$seq++;}
$local_file="$upload_dir/$the_time$seq";
};
rename($uploadfile,$local_file);
display_page();
}
display_page();function display_page()
{
//这是你的页面内容
}
?><html>
<head>
<title>php3 receiving script</title>
</head>
<body>
<?if ($error_msg){echo "<b>$error_msg</b><br><br>";}
if($sendit)
{
do_upload();
echo "文件上传成功!";
elseif($cancelit)
{
Header("Location:$some_other_script");
echo "文件上载失败!";
exit;
}
else
{some_other_func();
}
?>
</body>
</html>
/*test.php*/
<form enctype="multipart/form-data" action="save.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>/*save.php*/
<?php
// 在 4.1.0 以前的 PHP 中,需要用 $HTTP_POST_FILES 代替 $_FILES。
// 在 4.0.3 以前的 PHP 中,需要用 copy() 和 is_uploaded_file() 来代替 move_uploaded_file()。$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
?>你看下你的PHP版本是多少的
phpx的精华里面自己去找一下吧!!!