Home > Article > Backend Development > How to set the php image storage path
How to set the php picture storage path: first set "enctype="multipart/form-data"" in the html form; then get the temporary file name and upload file name through picture; finally store the uploaded file in Just specify the location.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to set the php image storage path?
php stores image files to the specified folder
The following settings need to be made in the html code when uploading files:
This part of the php code tests the specific content of the $_FILES file
<?php sleep(5);// 让服务器休息一会 print_r($_FILES); ?>
The running results are as follows
##Operation description: The code in the HTML part will not be changed
The following is the printed file related
Array ( [picture] => Array ( [name] => computer.png [type] => image/png [tmp_name] => D:\wamp\tmp\php8913.tmp [error] => 0 [size] => 5212 ) )The php code is as followsWe need to obtain the temporary file name and upload file name through picture (determined according to the name attribute of the form tag)
<?php sleep(5);// 让服务器休息一会,方便我们查看上传的临时文件 // 第一个参数是 规定要移动的文件 // 第二个参数是 规定文件的新位置 move_uploaded_file($_FILES['picture']['tmp_name'], './upload/'.$_FILES['picture']['name']); ?>rrree
PHP Video Tutorial"
The running results are as follows Be sure to ensure that the transfer folder has read and write permissionsThe above is the detailed content of How to set the php image storage path. For more information, please follow other related articles on the PHP Chinese website!