Home  >  Article  >  Backend Development  >  后台将图片传到服务器上的 但是在前台怎么显示,是不是代码的问题呢

后台将图片传到服务器上的 但是在前台怎么显示,是不是代码的问题呢

WBOY
WBOYOriginal
2016-06-23 13:54:401955browse

if(empty($_GET[submit])) 

?> 

?submit=1" method="post"> 
Upload small image:  
 
 
}else{ 
$path="uploadfile/"; //上传路径 
//echo $_FILES["filename"]["type"]; 
if(!file_exists($path)) 

//检查是否有该文件夹,如果没有就创建,并给予最高权限 
mkdir("$path" 0700); 
}//END IF 
//允许上传的文件格式 
$tp = array("image/gif""image/pjpeg""image/jpeg""image/png"); 
//检查上传文件是否在允许上传的类型 
if(!in_array($_FILES["filename"]["type"]$tp)) 

echo "File Type is incorrect"; 
exit; 
}//END IF 
if($_FILES["filename"]["name"]) 

$file1=$_FILES["filename"]["name"]; 
//$file2 = $path.time().$file1; 
//文件名称 取原文件名
$file2 = $path.$file1; 
$flag=1; 
}//END IF 
if($flag) $result=move_uploaded_file($_FILES["filename"]["tmp_name"]$file2); 
//特别注意这里传递给move_uploaded_file的第一个参数为上传到服务器上的临时文件 
if($result) 

//echo "上传成功!".$file2; 
echo "<script>"; <br /> echo "alert("Upload Success!");"; <br /> echo "</script>"; 
?>
?submit=1" method="post"> 
Upload small image:  
 
 
//显示路径下图片名称列表
$dirr = 'uploadfile/'; 
$dir = opendir($dirr); 
echo '

success!


'; 
echo 'File size:' . $_FILES['file']['size'] . 'byte' . '
'; 
echo 'File Path:' . $dirr; 
echo '
' . '

'; 
echo $dirr . '--Listing:

    '; 
    while($file = readdir($dir)){ 
    echo "
  • $file
  • "; 

    echo '
'; 
closedir($dir); 
}//END IF 

?>


回复讨论(解决方案)

大神们,帮忙看看吧。

move_uploaded_file($_FILES["filename"]["tmp_name"] , $file2);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn