Jump to content

Ken Lewis

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Ken Lewis

  1. I only pasted the main part of the code, the part of the code you mentioned is actually there.

    Design page:

    3.png

    Run page:  When I click btn1:
    1.png
     

    And when I click btn2:
    2.png

    Source Code:

    procedure TSysParamFrm.btn1Click(Sender: TObject);
    var
      tmpStream : TMemoryStream;
    begin
      tmpStream:=TMemorystream.Create;
      try
        with qryGetImage do
        begin
          Close;
          Open;
          if not IsEmpty then
          begin
            TBlobField(FieldByName('li_image')).SaveToStream(tmpStream);
            tmpStream.Position :=0;
            UniCanvas1.Color := clWhite;
            UniCanvas1.Clear;
            uniCanvas1.LoadFromStream(tmpStream);
          end;
          Close;
        end;
      finally
        FreeAndNil(tmpStream);
      end;
    end;
    
    procedure TSysParamFrm.btn2Click(Sender: TObject);
    var
      tmpStream : TMemoryStream;
    begin
      tmpStream:=TMemorystream.Create;
      try
        with qryGetImage do
        begin
          Close;
          Open;
          if not IsEmpty then
          begin
            TBlobField(FieldByName('li_image')).SaveToStream(tmpStream);
            tmpStream.Position :=0;
            UniCanvas1.Color := clWhite;
            UniCanvas1.Clear;
            tmpStream.SaveToFile(UniServerModule.StartPath +  'images/1.png');
            UniCanvas1.LoadFromFile(UniServerModule.StartPath +  'images/1.png');
          end;
          Close;
        end;
      finally
        FreeAndNil(tmpStream);
      end;
    end;

     

  2. UniGUI 1555

    var
      tmpStream : TMemoryStream;
    begin
      ......
      TBlobField(FieldByName('li_image')).SaveToStream(tmpStream);
      tmpStream.Position :=0;
      UniCanvas1.Color := clWhite;
      UniCanvas1.Clear;
      uniCanvas1.LoadFromStream(tmpStream);  //When I use this ,the picture is not shown;
      tmpStream.SaveToFile(UniServerModule.StartPath +  'images/1.png');
      UniCanvas1.LoadFromFile(UniServerModule.StartPath +  'images/1.png');  //The picture is shown;
    end;

     

  3. Sorry, when I use your code, a error messge showed "Error Status=0". I think, I should set a upload folder.

    But, I don't want to upload any file.

    And your code is excuted when a file has finished uploading. if the file size is very big, I have to wait for a long time. It  is not necessary.

×
×
  • Create New...