OSDN Git Service

画像は確認できました スタイルシートはどうでしょうか
authoryamat0jp <terukohietori@gmail.com>
Thu, 12 Mar 2020 12:46:47 +0000 (21:46 +0900)
committeryamat0jp <terukohietori@gmail.com>
Thu, 12 Mar 2020 12:46:47 +0000 (21:46 +0900)
Unit1.pas
WebModuleUnit1.pas

index 21c33be..c818f1c 100644 (file)
--- a/Unit1.pas
+++ b/Unit1.pas
@@ -95,7 +95,7 @@ type
     function loginReader(Data: TJSONObject): integer;
     function loginWriter(Data: TJSONObject): integer;
     procedure mainView(id: integer; out Data: TJSONObject);
-    procedure imageView(magid, newsId: integer; out Data: TJSONObject);
+    procedure imageView(magNum, name: string; newsId: integer; out Data: TJSONObject);
     procedure zipFile(id: integer; magNum: string; stream: TStream);
   end;
 
@@ -409,7 +409,7 @@ begin
       for i := 0 to list.Count - 1 do
         if Pos('../images/', list[i]) > 0 then
         begin
-          s2 := Format('/image?id=%d&name=', [id]);
+          s2 := Format('/image?num=%s&id=%d&name=', [magNum,id]);
           list[i] := ReplaceText(list[i], '../images/', s2);
         end
         else if Pos('../style/', list[i]) > 0 then
@@ -501,10 +501,15 @@ begin
   Data := makeTable(FDQuery1);
 end;
 
-procedure TDataModule1.imageView(magid, newsId: integer; out Data: TJSONObject);
+procedure TDataModule1.imageView(magNum, name: string; newsId: integer; out Data: TJSONObject);
+var
+  id: Variant;
 begin
+  id:=mag.Lookup('magnum',magnum,'magid');
+  if VarIsNull(id) = true then
+    exit;
   Data := TJSONObject.Create;
-  if image.Locate('magid,newsid', VarArrayOf([magid, newsId])) = true then
+  if image.Locate('magid;newsid;name', VarArrayOf([id, newsId,name])) = true then
   begin
     Data.AddPair('name', image.FieldByName('name').AsString);
     Data.AddPair('data', image.FieldByName('data').AsString);
index 7483594..73dec64 100644 (file)
@@ -120,16 +120,19 @@ end;
 procedure TWebModule1.WebModule1imageAction(Sender: TObject;
   Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
 var
-  magid, newsid: integer;
+  magnum, name: string;
+  newsid: integer;
   str: string;
   data: TJSONObject;
   mem: TMemoryStream;
   raw: TBytes;
 begin
   data := TJSONObject.Create;
-  magid := Request.QueryFields.Values['id'].ToInteger;
-  newsid := Request.QueryFields.Values['num'].ToInteger;
-  DataModule1.imageView(magid, newsid, data);
+  newsid:= Request.QueryFields.Values['id'].ToInteger;
+  magnum := Request.QueryFields.Values['num'];
+  name:=Request.QueryFields.Values['name'];
+  DataModule1.imageView(magNum, name, newsid, data);
+  str:=data.Values['data'].Value;
   mem := TMemoryStream.Create;
   if data.Values['encode'].Value = 'true' then
   begin
@@ -138,7 +141,7 @@ begin
     Finalize(raw);
   end
   else
-    mem.WriteBuffer(@str, Length(str));
+    mem.WriteBuffer(PChar(str)^, SizeOf(Char)*Length(str));
   mem.Position := 0;
   Response.ContentType := 'jpeg/image';
   Response.ContentStream := mem;