您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php如何存储图片

2025/3/29 15:58:37发布17次查看
php作为后端接受上传的图片还是很简单的,需要用到files,当客户端或web端向后端post图片时,我们可以用files,当客户端或web端向后端post图片时,我们可以用_file接收图片,然后存储在临时缓冲区中,最后用move_upload_file函数保存在本地。(推荐学习:php视频教程)
<?php $imgname = $_files['myfile']['name']; $tmp = $_files['myfile']['tmp_name']; $filepath = 'photo/'; if(move_uploaded_file($tmp,$filepath.$imgname.".png")){ echo "上传成功"; }else{ echo "上传失败"; }?>
代码:
/html代码<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>insert title here</title></head><body><form action="./uploadheadimg.php" method="post" enctype="multipart/form-data"><!-- <input type="hidden" name="max_file_size" value='176942' /> -->请选择您要上传的文件:<input type="file" name='myfile' /><!-- <input type="file" name="myfile" accept="image/jpeg,image/gif,image/png"/><br /> --><input type="submit" value="上传文件" /></form></body></html>
以上就是php如何存储图片的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product