這次的這篇文章介紹的是關於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-postman上傳圖片到伺服器的詳細內容。更多資訊請關注PHP中文網其他相關文章!