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
Release: 2023-03-01 13:42:02
Original
1310 people have browsed it

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.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template