文件上传常见php函数
2022年 06月 21 日

BIGFISH

1.file_exists()函数

  • file_exists() 函数检查文件或目录是否存在。

  • 如果指定的文件或目录则返回 TRUE,否则返回 FALSE。

  • 格式为file_exists(path)

2.move_uploaded_file()函数

  • move_uploaded_file() 函数把上传的文件移动到新位置。

  • 如果成功该函数返回 TRUE,如果失败则返回 FALSE。 格式为move_uploaded_file(file,newloc) 在文件上传时经常看见这个函数。 在这里插入图片描述

3.trim()函数

  • trim() 函数移除文字字符的字体或其他预定义的字符。

  • 格式为trim(string,charlist)

  • 在这里插入图片描述

4.deldot()函数

  • deldot(file_name); //删除文件名末尾的点

5.strrchr() 函数

  • strrchr() 函数查找字符串在另一个字符串中最后一次出现的位置,并返回从该位置到字符串结尾的所有字符。

  • 格式为strrchr(string,char) 在这里插入图片描述

6.strtolower()函数

  • strtolower() 函数把字符串转换为小写。 在这里插入图片描述

7.str_ireplace() 函数

  • str_ireplace() 函数替换字符串中的一些字符(不区分大小写)。

  • 格式为str_ireplace(find,replace,string,count) 在这里插入图片描述 在这里插入图片描述

8.in_array() 函数

  • in_array() 函数搜索数组中是否存在指定的值。

  • 格式为in_array ( 混合 $needle , 数组 $haystack [, bool $strict = FALSE ] ) 在这里插入图片描述

9.strrpos()函数

  • strrpos() 函数查找字符串在另一中最后一次出现的位置(时间大小写)。

  • 注释: strrpos() 函数是离散大小写的。

  • 格式为strrpos(string,find,start) 在这里插入图片描述 在这里插入图片描述

10.unpack()函数

  • unpack() 函数从二进制字符串对数据进行解包。

  • 格式为unpack(format,data) 在这里插入图片描述

11.getimagesize 函数 - 获取图像信息

  • getimagesize()函数用于获取图像大小及相关信息,成功返回一个数组,则失败返回FALSE并产生一条E_WARNING级的错误信息。 格式为数组 getimagesize ( string filename [, array &$imageinfo ] )

  • getimagesize() 函数将补任何 GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM 或 WBMP 图像文件的大小返回图像的尺寸以及文件类型及图片高度与宽度。

12.image_type_to_extension - 获取图片后缀

  • image_type_to_extension——根据指定的图像类型返回对应的后缀名

  • 格式为:image_type_to_extension ( int $imagetype [, bool $include_dot = TRUE ] )

13.exif_imagetype

  • exif_imagetype — 判断一个图像的类型,读取一个图像的第一个字节并检查其签名。

  • 格式为exif_imagetype ( string $filename ) : int

14.imagecreatefromjpeg()函数

  • imagecreatefromjpeg — 由文件或 URL 创建一个新图象,返回一图像标识符,代表了从给定的文件名取得的图像。

  • 格式为 imagecreatefromjpeg ( string $filename ) : resource

15.unlink() 函数

  • unlink() 函数删除文件。

  • 如果成功,则该函数返回 TRUE。如果失败,则返回 FALSE。 格式为 unlink(filename,context) 在这里插入图片描述

16.substr()函数

  • substr()函数返回指定字符串中的特定一部分,

  • 格式为substr(string,start,length)

17.strrpos()函数

  • strrpos() 函数查找字符串在另一字符串中最后一次出现的位置。

  • 格式strrpos(string,find,start)

  • 相关函数:



    • stripos()- 查找字符串在另一字符串中第一次出现的位置(不区分大小写)


    • strpos()- 查找字符串在另一字符串中第一次出现的位置(区分大小写)


    • strripos()- 查找字符串在另一字符串中最后一次出现的位置(不区分大小写)

18.save_path:保存参数的路径

19.move_uploaded_file() 函数

  • move_uploaded_file() 函数将上传的文件移动到新位置。

  • 若成功,则返回true,否则返回false

  • 格式为move_uploaded_file(flie,newloc)

文件上传常见php函数

1.file_exists()函数

  • file_exists() 函数检查文件或目录是否存在。

  • 如果指定的文件或目录则返回 TRUE,否则返回 FALSE。

  • 格式为file_exists(path)

2.move_uploaded_file()函数

  • move_uploaded_file() 函数把上传的文件移动到新位置。

  • 如果成功该函数返回 TRUE,如果失败则返回 FALSE。 格式为move_uploaded_file(file,newloc) 在文件上传时经常看见这个函数。 在这里插入图片描述

3.trim()函数

  • trim() 函数移除文字字符的字体或其他预定义的字符。

  • 格式为trim(string,charlist)

  • 在这里插入图片描述

4.deldot()函数

  • deldot(file_name); //删除文件名末尾的点

5.strrchr() 函数

  • strrchr() 函数查找字符串在另一个字符串中最后一次出现的位置,并返回从该位置到字符串结尾的所有字符。

  • 格式为strrchr(string,char) 在这里插入图片描述

6.strtolower()函数

  • strtolower() 函数把字符串转换为小写。 在这里插入图片描述

7.str_ireplace() 函数

  • str_ireplace() 函数替换字符串中的一些字符(不区分大小写)。

  • 格式为str_ireplace(find,replace,string,count) 在这里插入图片描述 在这里插入图片描述

8.in_array() 函数

  • in_array() 函数搜索数组中是否存在指定的值。

  • 格式为in_array ( 混合 $needle , 数组 $haystack [, bool $strict = FALSE ] ) 在这里插入图片描述

9.strrpos()函数

  • strrpos() 函数查找字符串在另一中最后一次出现的位置(时间大小写)。

  • 注释: strrpos() 函数是离散大小写的。

  • 格式为strrpos(string,find,start) 在这里插入图片描述 在这里插入图片描述

10.unpack()函数

  • unpack() 函数从二进制字符串对数据进行解包。

  • 格式为unpack(format,data) 在这里插入图片描述

11.getimagesize 函数 - 获取图像信息

  • getimagesize()函数用于获取图像大小及相关信息,成功返回一个数组,则失败返回FALSE并产生一条E_WARNING级的错误信息。 格式为数组 getimagesize ( string filename [, array &$imageinfo ] )

  • getimagesize() 函数将补任何 GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM 或 WBMP 图像文件的大小返回图像的尺寸以及文件类型及图片高度与宽度。

12.image_type_to_extension - 获取图片后缀

  • image_type_to_extension——根据指定的图像类型返回对应的后缀名

  • 格式为:image_type_to_extension ( int $imagetype [, bool $include_dot = TRUE ] )

13.exif_imagetype

  • exif_imagetype — 判断一个图像的类型,读取一个图像的第一个字节并检查其签名。

  • 格式为exif_imagetype ( string $filename ) : int

14.imagecreatefromjpeg()函数

  • imagecreatefromjpeg — 由文件或 URL 创建一个新图象,返回一图像标识符,代表了从给定的文件名取得的图像。

  • 格式为 imagecreatefromjpeg ( string $filename ) : resource

15.unlink() 函数

  • unlink() 函数删除文件。

  • 如果成功,则该函数返回 TRUE。如果失败,则返回 FALSE。 格式为 unlink(filename,context) 在这里插入图片描述

16.substr()函数

  • substr()函数返回指定字符串中的特定一部分,

  • 格式为substr(string,start,length)

17.strrpos()函数

  • strrpos() 函数查找字符串在另一字符串中最后一次出现的位置。

  • 格式strrpos(string,find,start)

  • 相关函数:



    • stripos()- 查找字符串在另一字符串中第一次出现的位置(不区分大小写)


    • strpos()- 查找字符串在另一字符串中第一次出现的位置(区分大小写)


    • strripos()- 查找字符串在另一字符串中最后一次出现的位置(不区分大小写)

18.save_path:保存参数的路径

19.move_uploaded_file() 函数

  • move_uploaded_file() 函数将上传的文件移动到新位置。

  • 若成功,则返回true,否则返回false

  • 格式为move_uploaded_file(flie,newloc)

赞 (0)

猜您想看

评论区(暂无评论)

这里空空如也,快来评论吧~

我要评论