TWebLocalTextFile

How can i find a sample to write an base64 Image to local HD as Textfile

If your image is in a TWebImageControl, you could use:

var
  s: string;
begin
  s := webimagecontrol1.Base64Image;
  WebLocalTextFile1.Text := s;
  weblocaltextfile1.SaveAsFile();
end;

Thanks, for this sample!

Here my code.

procedure TForm1.wbScanSnClick(Sender: TObject);
var
ImageData : string;
ImageDataUrl : string;

Filename        : string;

begin
// Actuelles Bild in Vorschau
WebImageControl.Url := WebCamera.SnapShotAsBase64;

ImageData       := WebCamera.SnapShotAsBase64;
ImageDataUrl    := 'data:image/png;base64,' + ImageData;

// make filename
FileName := 'C:/temp/'      +                                               // Pfad
             weAbNr.Text + '_' +                                            // Auftrag
             FormatDateTime('dd-mm-yyyy', now) + '_' +                      // Datum
             IntToStr(lfdNr) + '.jpg' ;                                     // lfdNr

// add filename to ListBox
WebListBox.Items.Add(FileName);
inc(lfdNr);

lTextFile.Text := ImageData;
lTextFile.SaveFile();

end;

When i do this, I have always the error in Atachmaent, how ca i get the FileHandler?

In web , you cannot just set a filename hardcoded. If that were possible, it would be a huge security issue.
You should call SaveAsFile() to let the user pick the filename (and in the process verify himself this file will not overwrite any other file)

Thanks for this Info. Is there a way to save a file without "Save Dialog"

MfG

After you open a file (and yes, you'll have a dialog to pick the file) you can save it again.
But just specifying a hardcoded filename and expect it to save from a browser is a big NO GO for a browser as it is a huge security breach.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.