谁能帮我解决php上传图片问题 10
代码如下,就是不能实现图片上传功能,哪位好心人帮我解决一下。。。functiongetname($exname){$dir="upimages/";$i=1;if(!is...
代码如下,就是不能实现图片上传功能,哪位好心人帮我解决一下。。。
function getname($exname){
$dir = "upimages/";
$i=1;
if(!is_dir($dir)){
mkdir($dir,0777);
}
while(true){
if(!is_file($dir.$i.".".$exname)){
$name=$i.".".$exname;
break;
}
$i++;
}
return $dir.$name;
}
$exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1)));
$uploadfile = getname($exname);
move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile);
if(trim($_FILES['upfile']['name']!=""))
{
$uploadfile="admin/".$uploadfile;
}
else
{
$uploadfile="";
} 展开
function getname($exname){
$dir = "upimages/";
$i=1;
if(!is_dir($dir)){
mkdir($dir,0777);
}
while(true){
if(!is_file($dir.$i.".".$exname)){
$name=$i.".".$exname;
break;
}
$i++;
}
return $dir.$name;
}
$exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1)));
$uploadfile = getname($exname);
move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile);
if(trim($_FILES['upfile']['name']!=""))
{
$uploadfile="admin/".$uploadfile;
}
else
{
$uploadfile="";
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询