请哪位高手详细说一下文件上传的问题 例子一大堆,但是照着做都不行。我的客户端是win,服务器端是linux :( 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我这里有一个文件,你看看<?session_start();require"../config.php";require"../check2.php";?><html><head><title>文件上传</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><form action="" method="post" enctype="multipart/form-data" name="form1"> <table width="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000CC"> <tr> <td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0"> <tr bgcolor="#F6F6F6"> <td width="181"> </td> <td width="419"> </td> </tr> <tr bgcolor="#F6F6F6"> <td colspan="2"><div align="center"><strong><font color="#006633">文 件 上 传</font></strong></div></td> </tr> <tr bgcolor="#F6F6F6"> <td> </td> <td> </td> </tr> <tr bgcolor="#F6F6F6"> <td><div align="right"><font color="#003366" size="2">所属类别:</font></div></td> <td><select name="lei" size="1"> <option>***请选择***</option> <option value="yg">员工照片</option> <option value="open">开料整形系列</option> <option value="hot">热压烫压系列</option> <option value="heigh">高频机系列</option> <option value="gule">胶水涂布系列</option> </select></td> </tr> <tr bgcolor="#F6F6F6"> <td height="27"><div align="right"><font color="#003366" size="2">文件名称:</font></div></td> <td><input type="text" name="name1"></td> </tr> <tr bgcolor="#F6F6F6"> <td><div align="right"><font color="#003366" size="2">说明内容 <input type="hidden" name="cbg" value="clf"> :</font></div></td> <td><textarea name="intro" cols="50" rows="6"></textarea></td> </tr> <tr bgcolor="#F6F6F6"> <td height="34"><div align="right"><font color="#003366" size="2">请选择要上传的文件:</font></div></td> <td> <input type="hidden" name="PHP_MAX_SIZE" value="1000000"> <input type="file" name="picfile"> </td> </tr> <tr bgcolor="#F6F6F6"> <td height="46" colspan="2"><div align="center"> <input type="submit" name="submit" value="上传文件"> <input type="reset" name="Reset" value="全部重置"> </div></td> </tr> <tr bgcolor="#F6F6F6"> <td> </td> <td> </td> </tr> </table></td> </tr> </table></form></body></html><?if($cbg=="clf"){ if($picfile!="") { $path="image3/"; @mkdir($path); $exten=strchr($picfile_name,"."); $newpicfile="pic".date("YmdHis").$exten; $newpicfiles=$newpicfile; $newpic=$path.$newpicfile; echo $newpicfile; if(copy($picfile,$newpic)) { echo"图片上载成功<br>"; } else { echo"图片上载失败!"; } unlink($picfile); } else { echo"请选择要上传的图片<meta http-equiv=refresh content=1;url=upload.php>"; }$connect=mysql_connect($host,$root,$pas);mysql_select_db($db);$result2=mysql_query("select * from $pic");$query="insert into $pic(lei,name1,intro,picname) values('$lei','$name1','$intro','$newpicfile')";$result=mysql_query($query);echo $result."<br>";if($result){echo"添加成功";}else{echo"添加失败";}mysql_close($connect);}?> <?php if($ima_name!=""){$extname=substr($ima_name,-3); if($extname!="gif"&&$extname!="jpg") //判断图片格式 { header("location:test.php?err=图片格式错误!"); exit; } else { $utime=time(); $pic="../image/".$utime.$ima_name; //图片上传到的路径+文件名称 $pic2=$utime.$ima_name; //文件名称 copy($ima,$pic); }} ?><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1"><input name="ima" type="file" id="ima"></form> 我如果加了 enctype="multipart/form-data" 这句后 $_POST["file"]或$_FILE["file"]["name"]等就都没有值了??而我不加的话,在运行到ftp_put()函数时就报错?? 晕~是$_FILES而非$_FILE精华区很多例子,看看嘛 我的程序就是照着例子做了,但总是在ftp_put()函数出错???在php.ini中哪项是配置ftp或http上传的谢谢! ftp、http和表单上传根本就不同,怎么能混合使用?该用什么就用什么。 我是先试了http方式不行,然后改用ftp方式的,但也不行。问一下,用ftp方式,是不是不用加: enctype="multipart/form-data" ? 你用的是ftp长传,首先要保证你有ftp服务器,比如server-U。php.ini:allow_url_fopen = On最好还是用http方式的,用copy函数 php Snoopy 能用来发邮件不? 帮我看看这个正则错在哪里? 关于php数组的问题 关于 exit GD库如何得理动态的GIF图片? 这条正则的正确格式应该是什么? 下载的mysql没有winmysqladmin.exe 文件?? 这样的结构如何做导航 请问如何用得到屏幕的分辨率? PHP数组问题,数组中加入KEY 如何获得mysql当前的连接数? explode()问题
<?
session_start();
require"../config.php";
require"../check2.php";
?>
<html>
<head>
<title>文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<table width="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000CC">
<tr>
<td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#F6F6F6">
<td width="181"> </td>
<td width="419"> </td>
</tr>
<tr bgcolor="#F6F6F6">
<td colspan="2"><div align="center"><strong><font color="#006633">文
件 上 传</font></strong></div></td>
</tr>
<tr bgcolor="#F6F6F6">
<td> </td>
<td> </td>
</tr>
<tr bgcolor="#F6F6F6">
<td><div align="right"><font color="#003366" size="2">所属类别:</font></div></td>
<td><select name="lei" size="1">
<option>***请选择***</option>
<option value="yg">员工照片</option>
<option value="open">开料整形系列</option>
<option value="hot">热压烫压系列</option>
<option value="heigh">高频机系列</option>
<option value="gule">胶水涂布系列</option>
</select></td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="27"><div align="right"><font color="#003366" size="2">文件名称:</font></div></td>
<td><input type="text" name="name1"></td>
</tr>
<tr bgcolor="#F6F6F6">
<td><div align="right"><font color="#003366" size="2">说明内容
<input type="hidden" name="cbg" value="clf">
:</font></div></td>
<td><textarea name="intro" cols="50" rows="6"></textarea></td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="34"><div align="right"><font color="#003366" size="2">请选择要上传的文件:</font></div></td>
<td> <input type="hidden" name="PHP_MAX_SIZE" value="1000000"> <input type="file" name="picfile">
</td>
</tr>
<tr bgcolor="#F6F6F6">
<td height="46" colspan="2"><div align="center">
<input type="submit" name="submit" value="上传文件">
<input type="reset" name="Reset" value="全部重置">
</div></td>
</tr>
<tr bgcolor="#F6F6F6">
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
<?
if($cbg=="clf")
{
if($picfile!="")
{
$path="image3/";
@mkdir($path);
$exten=strchr($picfile_name,".");
$newpicfile="pic".date("YmdHis").$exten;
$newpicfiles=$newpicfile;
$newpic=$path.$newpicfile;
echo $newpicfile;
if(copy($picfile,$newpic))
{
echo"图片上载成功<br>";
}
else
{
echo"图片上载失败!";
}
unlink($picfile);
}
else
{
echo"请选择要上传的图片<meta http-equiv=refresh content=1;url=upload.php>";
}
$connect=mysql_connect($host,$root,$pas);
mysql_select_db($db);
$result2=mysql_query("select * from $pic");
$query="insert into $pic(lei,name1,intro,picname) values('$lei','$name1','$intro','$newpicfile')";
$result=mysql_query($query);echo $result."<br>";
if($result)
{
echo"添加成功";
}
else
{
echo"添加失败";
}
mysql_close($connect);
}
?>
if($ima_name!="")
{
$extname=substr($ima_name,-3);
if($extname!="gif"&&$extname!="jpg") //判断图片格式
{
header("location:test.php?err=图片格式错误!");
exit;
}
else
{
$utime=time();
$pic="../image/".$utime.$ima_name; //图片上传到的路径+文件名称
$pic2=$utime.$ima_name; //文件名称
copy($ima,$pic);
}
}
?><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
<input name="ima" type="file" id="ima">
</form>
而我不加的话,在运行到ftp_put()函数时就报错??
是$_FILES而非$_FILE精华区很多例子,看看嘛
php.ini:allow_url_fopen = On
最好还是用http方式的,用copy函数