<?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如何存储图片的详细内容。
