后台将图片传到服务器上的 但是在前台怎么显示,是不是代码的问题呢
Jun 23, 2016 pm 01:54 PM if(empty($_GET[submit]))
{
?>
}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>";
?>
//显示路径下图片名称列表
$dirr = 'uploadfile/';
$dir = opendir($dirr);
echo '
success!
';
echo 'File size:' . $_FILES['file']['size'] . 'byte' . '
';
echo 'File Path:' . $dirr;
echo '
' . '
';
echo $dirr . '--Listing:
- ';
- $file ";
while($file = readdir($dir)){
echo "
}
echo '
closedir($dir);
}//END IF
}
?>
回复讨论(解决方案)
大神们,帮忙看看吧。
move_uploaded_file($_FILES["filename"]["tmp_name"] , $file2);

Hot tools Tags

Hot Article

Hot tools Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Discuz background login problem solution revealed

Best Practice Guide for Building IP Proxy Servers with PHP

How to configure Dnsmasq as a DHCP relay server

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

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

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
