应用move_uploaded_file()函数上传时出错,提示路径错误。
代码:<form action="" enctype="multipart/form-data" method="post">
<tr>
<td width="150" height="30" align="right" valign="middle">请选择上传文件</td>
<td width="250"><input type="file" name="fileup" /></td>
<td width="100"><input type="submit" name="submit" value="上传" /></td>
</tr>
</form>
<?php
if(!empty($_FILES[fileup][name])){
$fileinfo=$_FILES[fileup];
$type=strstr($fileinfo['name'],".");
if($type!=".jpg"){
echo "您上传的文件格式不正确!";
}else{
if($fileinfo['size']<209715 && $fileinfo['size']>0){
$path="10/".$_FILES["fileup"]["name"];
move_uploaded_file($fileinfo['tmp_name'],$path);
if(is_dir("10/")){
$dir=scandir("10/");
foreach($dir as $value){
echo $value."<br/>";
}
}else{
echo "目录路径出错!";
}
}else{
echo '文件大小不符合要求!';
}
}
}
?>
运行结果:
Warning: move_uploaded_file(10/02.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in E:\appserv-win32-2.5.10\AppServ\www\10\index_7.php on line 26
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\temp\php1A.tmp' to '10/02.jpg' in E:\appserv-win32-2.5.10\AppServ\www\10\index_7.php on line 26
目录路径出错! 帮帮忙,看看什么地方出错了呢?