teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

例示ドメインに変更しました。

2020/05/30 22:49

投稿

sun2tomonori
sun2tomonori

スコア5

title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,7 @@
11
11
  header("Content-type:application/json; charset=utf8");
12
12
  header("Access-Control-Allow-Origin: *");
13
13
 
14
- const SERVER_URL = 'https://sample.com/';
14
+ const SERVER_URL = 'https://hogetest.com/';
15
15
  const SAVE_FOLDER_PATH = "image/testImage/";
16
16
 
17
17
  $result = '';
@@ -42,7 +42,7 @@
42
42
  ?>
43
43
  ```
44
44
  ■実行結果
45
- "https://sample.com/image/testImage/imgYYYYMMDDhhmmss_uniqueid.jpg"
45
+ "https://hogetest.com/image/testImage/imgYYYYMMDDhhmmss_uniqueid.jpg"
46
46
 
47
47
  ### 試したこと
48
48
  コード上にもありますが、str_replace()を試しても結果は同じでした。

1

追記しました

2020/05/30 22:49

投稿

sun2tomonori
sun2tomonori

スコア5

title CHANGED
File without changes
body CHANGED
@@ -49,4 +49,38 @@
49
49
 
50
50
  ### 補足情報(FW/ツールのバージョンなど)
51
51
  レンタルサーバーで実行しています。
52
- PHPバージョン:PHP7.3.16
52
+ PHPバージョン:PHP7.3.16
53
+
54
+
55
+ ### 追記
56
+ js側での受け取り方変えたらうまくいきました。
57
+ が、なぜそのようなことが起こるのでしょうか...
58
+
59
+ ```Javasclipt
60
+ /* old */
61
+ // let fd = new FormData($('#send-form').get(0));
62
+ // let str = $.ajax({
63
+ // url: 'sample.php',
64
+ // type: 'POST',
65
+ // data: fd,
66
+ // cache: false,
67
+ // contentType: false,
68
+ // processData: false,
69
+ // async: false
70
+ // }).responseText;
71
+ //
72
+ // alert(str);
73
+
74
+ /* new */
75
+ let fd = new FormData($('#send-form').get(0));
76
+ $.ajax({
77
+ url: 'sample.php',
78
+ type: 'POST',
79
+ data: fd,
80
+ cache: false,
81
+ contentType: false,
82
+ processData: false,
83
+ }).done(function(str) {
84
+ alert(str);
85
+ });
86
+ ```