Home >Backend Development >PHP Tutorial >php-student, please give me some comments on the code for uploading images below. I don't know how to implement it.

php-student, please give me some comments on the code for uploading images below. I don't know how to implement it.

WBOY
WBOYOriginal
2016-11-30 23:59:541305browse

Comment php

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="";
}

Reply Content:

http://www.jb51.net/article/25796.htm

https://zhidao.baidu.com/question/518135733.html
Take a look at this, it should help you.

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