· 7 years ago · Jun 20, 2018, 04:22 AM
1const data = new FormData();
2
3data.append("title", this.state.title);
4data.append("file", this.state.file[0]);
5
6createDownloadableForm(data);
7
8public function actionCreate()
9{
10 $request = Yii::app()->request;
11 // ???
12}
13
14Yii::log($request); // <~ nothing about what is coming, even if it is a simple JSON request, it does not show it like this.
15Yii::log($_FILES or $_POST); // <~ []
16Yii::log($_FILES['files'] or $_POST['title']); // <~ error
17...
18
19export function createDownloadableForm(data) {
20 return (dispatch, getState) => {
21 const { auth: { oauthToken, oauthTokenSecret } } = getState();
22
23 return dispatch({
24 [CALL_API]: {
25 endpoint: "/api/downloadable-forms",
26 method: "POST",
27 headers: {
28 'xoauthtoken': oauthToken,
29 'xoauthtokensecret': oauthTokenSecret,
30 },
31 body: data,
32 types: [CREATE_DOWNLOADABLE_FORMS, CREATE_DOWNLOADABLE_FORMS_SUCCESS, CREATE_DOWNLOADABLE_FORMS_FAILURE]
33 }
34 })
35 }
36}