Table of Contents
success!
回复讨论(解决方案)
Home Backend Development PHP Tutorial 后台将图片传到服务器上的 但是在前台怎么显示,是不是代码的问题呢

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

Jun 23, 2016 pm 01:54 PM
code Backstage show server

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 of this Website
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

Hot Article

Hot tools Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Discuz background login problem solution revealed Discuz background login problem solution revealed Mar 03, 2024 am 08:57 AM

Discuz background login problem solution revealed

Best Practice Guide for Building IP Proxy Servers with PHP Best Practice Guide for Building IP Proxy Servers with PHP Mar 11, 2024 am 08:36 AM

Best Practice Guide for Building IP Proxy Servers with PHP

How to configure Dnsmasq as a DHCP relay server How to configure Dnsmasq as a DHCP relay server Mar 21, 2024 am 08:50 AM

How to configure Dnsmasq as a DHCP relay server

GE universal remote codes program on any device GE universal remote codes program on any device Mar 02, 2024 pm 01:58 PM

GE universal remote codes program on any device

What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline Mar 13, 2024 pm 04:40 PM

What should I do if I can't enter the game when the epic server is offline? Solution to why Epic cannot enter the game offline

Are you worried about WordPress backend garbled code? Try these solutions Are you worried about WordPress backend garbled code? Try these solutions Mar 05, 2024 pm 09:27 PM

Are you worried about WordPress backend garbled code? Try these solutions

How to install PHP FFmpeg extension on server? How to install PHP FFmpeg extension on server? Mar 28, 2024 pm 02:39 PM

How to install PHP FFmpeg extension on server?

Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Jun 12, 2024 pm 08:38 PM

Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing

See all articles