这次的这篇文章介绍的是关于php-postman上传图片到服务器的内容,现在分享给大家,有需要的小伙伴可以参考一下

public function byte(){
$base_path = "./uploads/"; //存放目录
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 was an error uploading the file, please try again!" . $_FILES ['upload'] ['error']
);
exit(json_encode ( $array ));
}
}| 请求方式 | 参数 | 是否必须 | 参数说明 |
|---|---|---|---|
| POST | upload | Y | 所要上传的文件 |

相关推荐:
立即学习“PHP免费学习笔记(深入)”;
以上就是PHP-postman上传图片到服务器的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号