Home  >  Article  >  Web Front-end  >  Detailed explanation of PHP image simple upload function

Detailed explanation of PHP image simple upload function

墨辰丷
墨辰丷Original
2018-05-09 16:01:011447browse

This article mainly introduces the simple upload function of PHP pictures in detail, which has certain reference value. Interested friends can refer to it.

The following is the code:

<?php  
if ($HTTP_POST_VARS["upload"]=="上传"){  
file://这里你可以加上检查文件名,格式,图片尺寸等功能,  
file://$picurl 本地系统的全路径  
file://$picurl_name 上传后的临时文件名  
file://$picurl_size 文件的大小(字节)  
file://$picurl_type 文件的MIME类型  

copy("$picurl","/where/you/want/put/the/uploaded/files/in/$picurl_name");  
exit;  
}  
?>  
<form action="." method="post" enctype="multipart/form-data" name="UL">  
<!--注意:这里必须加上‘enctype="multipart/form-data" &#39;,否则不会产生上  
传动作-->  
<input type="file" name="picurl" size="15"  
accept="image/x-png,image/gif,image/jpeg">  
<input type="submit" name="upload" value="上传">  
</form>

Summary:

php uploads images, generally using the move_uploaded_file method to save them on the server . But if a website has multiple servers, it needs to publish pictures to all servers for normal use (except those using picture servers)

If the picture data is saved in the database, it can be achieved between multiple servers File sharing, saving space.

Related recommendations:

China Good Voice Jin Zhiwen is not that simple. PHP implements simple image uploading

##PHP Implement simple image upload_php basics

PHP implement simple image upload_PHP tutorial

The above is the detailed content of Detailed explanation of PHP image simple upload function. For more information, please follow other related articles on the PHP Chinese website!

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