上传图片的部分源码解析

echo "";
$fileName=$_FILES["file"]["name"];      //获取文件的名称
//echo $fileName;die();
$fileType=explode(".",$fileName);
$fileTypeName=$fileType[count($fileType)-1];
$typeArray=array("JPEG","gif","bmp"); //文件上传的规格类型
if(!in_array($fileTypeName,$typeArray))
{
echo "格式错误 本例只许上传图片格式为gif bmp和jpeg 请点击这里返回从新选择图片";
die();
}
if($_FILES['file']['error']>0)
{
echo "文件上传失败";
}
else
{
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
if(move_uploaded_file($_FILES['file']['tmp_name'],'images/'.$_FILES['file']['name']))
{
//move_uploaded_file方法是,当你上传图片(文件)的时候,首先将图片(文件)保存在系统的临时目录中,然后通过move_uploaded_file方法,将文件传入指定的目录当中,第一个参数为文件的临时文件名,第二个参数为文件传入的目录指定。
echo "文件上传成功";
}
else
{
echo "移动目标位置失败";
}
}
else
{
echo "文件未被上传";
}
}
?>

Need a translation service?

Please enter your personal details and we will contact you shortly

Words translated by CCJK

146,096,379

We are Certified

Our Client Satisfaction

rating for previous quarte

4.00

Over 95% of our clients recommend our language services to others

Copyright © CCJK Technologies Co., Ltd. 2000-2017. All rights reserved.
TOP