how to html form post - file uploading and reading json response from php server

后端 未结 5 1578
名媛妹妹
名媛妹妹 2020-12-18 06:42

i am trying file uploading to php my server.file and data uploading through multi part /form-data ,the file and data received on php server but in my php server return json

5条回答
  •  抹茶落季
    2020-12-18 07:15

    Your JSON response would be a kind of associative array in php. Encode your array data into JSON using "json_encode" and return values as you want .

       $arr = array('status' => $status, 'status2' => $status2, );
       echo json_encode($arr);
    

    NOTE: If you are using ajax to call php file then do not use any php echo/print in that file and not even HTML. ECHO only "json_encode();" Nothing else.

提交回复
热议问题