質問編集履歴

5

ダウンロードしたデータの中身がうまく取得できていない。

2017/03/22 02:58

投稿

tundeco
tundeco

スコア17

test CHANGED
File without changes
test CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  |user_file_type|user_file_name|user_file_size|user_file|
58
58
 
59
- |:--|:--:|:--:|--:|
59
+ |:--|:--|:--|:--|
60
60
 
61
61
  |VARCHAR(255)|VARCHAR(255)|int(11)|MEDIUMBLOB|
62
62
 

4

ダウンロードしたデータの中身がうまく取得できていない。

2017/03/22 02:57

投稿

tundeco
tundeco

スコア17

test CHANGED
File without changes
test CHANGED
@@ -54,13 +54,17 @@
54
54
 
55
55
  MySQLの定義は下記の通りになります。
56
56
 
57
+ |user_file_type|user_file_name|user_file_size|user_file|
58
+
59
+ |:--|:--:|:--:|--:|
60
+
61
+ |VARCHAR(255)|VARCHAR(255)|int(11)|MEDIUMBLOB|
62
+
63
+ |ExcelやWordなどファイル形式は指定せず、ファイルタイプがセットされる。|ファイル名がセットされる。|ファイルのサイズがセットされる|ファイルそのものがバイナリでセットされる。|
64
+
57
65
  user_file_type(VARCHAR):ExcelやWordなどファイル形式は指定せず、ファイルタイプがセットされる。
58
66
 
59
- 例)application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
67
+ user_file_typeの例)application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
60
-
61
- user_file_name(VARCHAR):ファイル名がセットされる。
62
-
63
- user_file(MEDIUMBLOB):ファイルそのものがセットされる。
64
68
 
65
69
 
66
70
 

3

ダウンロードしたデータの中身がうまく取得できていない。

2017/03/22 02:57

投稿

tundeco
tundeco

スコア17

test CHANGED
File without changes
test CHANGED
@@ -66,9 +66,11 @@
66
66
 
67
67
  ご回答お願い致します。
68
68
 
69
- ---
69
+
70
70
 
71
71
  **追記・変更**
72
+
73
+ ---
72
74
 
73
75
  Controllerをソースの通り、
74
76
 

2

ダウンロードしたデータの中身がうまく取得できていない。

2017/03/22 02:49

投稿

tundeco
tundeco

スコア17

test CHANGED
File without changes
test CHANGED
@@ -66,9 +66,9 @@
66
66
 
67
67
  ご回答お願い致します。
68
68
 
69
+ ---
69
70
 
70
-
71
- 追記・変更
71
+ **追記・変更**
72
72
 
73
73
  Controllerをソースの通り、
74
74
 

1

ダウンロードしたデータの中身がうまく取得できていない。

2017/03/22 02:28

投稿

tundeco
tundeco

スコア17

test CHANGED
File without changes
test CHANGED
@@ -32,11 +32,21 @@
32
32
 
33
33
  $this->autoRender = false;
34
34
 
35
- $this->response->type($user->user_file_type);
35
+ // $this->response->type($user->user_file_type);
36
36
 
37
- $this->response->file($user->user_file); //ここの引数をどうしたらよいかで詰まっています。
37
+ // $this->response->file($user->user_file); //ここの引数をどうしたらよいかで詰まっています。
38
38
 
39
- $this->response->download($user->user_file); //ここの引数をどうしたらよいかで詰まっています。
39
+ // $this->response->download($user->user_file); //ここの引数をどうしたらよいかで詰まっています。
40
+
41
+ header('Content-type: ' . $user['user_file_type']);
42
+
43
+ header('Content-length: ' . $user['user_file_size']);
44
+
45
+ header('Content-Disposition: attachment; filename="'.$user['user_file_name'].'"');
46
+
47
+ echo $user['user_file'];
48
+
49
+
40
50
 
41
51
  }
42
52
 
@@ -55,3 +65,17 @@
55
65
 
56
66
 
57
67
  ご回答お願い致します。
68
+
69
+
70
+
71
+ 追記・変更
72
+
73
+ Controllerをソースの通り、
74
+
75
+ headerをセットして、echoでファイルを指定するように変更したところ、
76
+
77
+ DBのファイル名でダウンロードされるようにはなったのですが、
78
+
79
+ 中身がすべて「Resource id #000」となってしまいます。
80
+
81
+ BLOBに格納したデータが正しくダウンロードする方法をご存知の方がいらっしゃいましたらご回答お願い致します。