This article is mainly to share with you postman upload images to the server method, combined with the form of graphics, hope to help everyone.
1. Settings for postman:
2. PHP Code:
Public Function byte () { $base _path = "./uploads/";//Store directory if (!is_dir ($base _path)) { mkdir ($base _path, 0777,true); } $target _path = $base _path. basename ($_files [' Upload '] [' name ']); if (Move_uploaded_file ($_files [' Upload '] [' tmp_name '], $target _path)) { $info [' mess '] = ' OK '; $info [' flag '] = 0; Exit (Json_encode ($info)); } else { $array = array ( "flag" = + 0, "mess" = "There is an" error uploading the file, please try Aga In! ". $_files [' Upload '] [' ERROR '] ; Exit (Json_encode ($array));} }
3. API Description:
Request Method |
Parameters |
whether you must |
parameter Description |
POST |
Upload |
Y |
The file that you want to upload |
1. Settings for postman:
2. PHP Code:
Public Function byte () { $base _path = "./uploads/";//Store directory if (!is_dir ($base _path)) { mkdir ($base _path, 0777,true); } $target _path = $base _path. basename ($_files [' Upload '] [' name ']); if (Move_uploaded_file ($_files [' Upload '] [' tmp_name '], $target _path)) { $info [' mess '] = ' OK '; $info [' flag '] = 0; Exit (Json_encode ($info)); } else { $array = array ( "flag" = + 0, "mess" = "There is an" error uploading the file, please try Aga In! ". $_files [' Upload '] [' ERROR '] ; Exit (Json_encode ($array));} }
3. API Description:
Request Method |
Parameters |
whether you must |
parameter Description |
POST |
Upload |
Y |
The file that you want to upload |