Iwfileuploader official Demo

Source: Internet
Author: User

Unit Unit7;


Interface

Uses
Classes, Sysutils, Iwappform, Iwapplication, Iwcolor, Iwtypes, Vcl.controls,
Iwvclbasecontrol, Iwbasecontrol, Iwbasehtmlcontrol, Iwcontrol,
Iwcompfileuploader, Iwcomplabel, data.db, datasnap.dbclient;

Type
TIWFORM7 = Class (Tiwappform)
Iwfileuploader1:tiwfileuploader;
Iwlabel1:tiwlabel;
Iwlabel2:tiwlabel;
Iwfileuploader2:tiwfileuploader;
Iwlabel3:tiwlabel;
Iwfileuploader3:tiwfileuploader;
Clientdataset1:tclientdataset;
Clientdataset1filename:tstringfield;
Clientdataset1filesize:tintegerfield;
Clientdataset1filecontent:tblobfield;
Iwlabel4:tiwlabel;
Iwfileuploader4:tiwfileuploader;
Procedure iwfileuploader1asyncuploadcompleted (Sender:tobject; var destpath,
filename:string; var SaveFile, Overwrite:boolean);
Procedure iwfileuploader2asyncuploadcompleted (Sender:tobject; var destpath,
filename:string; var SaveFile, Overwrite:boolean);
Procedure iwfileuploader3asyncuploadcompleted (Sender:tobject; var destpath,
filename:string; var SaveFile, Overwrite:boolean);
Procedure Iwappformcreate (Sender:tobject);
Public
End

Implementation

{$R *.DFM}

Uses
IW.Common.AppInfo;

Procedure Tiwform7.iwappformcreate (Sender:tobject);
Begin
Create The DataSet so we can use it later
Clientdataset1.createdataset;
End

Procedure tiwform7.iwfileuploader1asyncuploadcompleted (Sender:tobject;
var destpath, filename:string; var SaveFile, Overwrite:boolean);
Var
curdir:string;
Begin
Get the app Path
CurDir: = Tiwappinfo.getapppath;

Save in the same application directory, with the same name of the the original file. Overwrite if it already exists.
Iwfileuploader1.savetofile (filename, CurDir + filename, True);

Inform Iwfileuploader that we is taking care of file saving ourselves
SaveFile: = False;
End

Procedure tiwform7.iwfileuploader2asyncuploadcompleted (Sender:tobject;
var destpath, filename:string; var SaveFile, Overwrite:boolean);
Begin
Here we just inform the new name for the file. Iwfileuploader'll take care of the rest.
The file would be saved inside the user cache directory (WEBAPPLICATION.USERCACHEDIR)
FileName: = ' MyUploadedFile.dat ';
End

Procedure tiwform7.iwfileuploader3asyncuploadcompleted (Sender:tobject;
var destpath, filename:string; var SaveFile, Overwrite:boolean);
Var
Ms:tmemorystream;
Begin
Create any TStream descendant
MS: = tmemorystream.create;
Try
Save the file content to the stream
Iwfileuploader3.savetostream (FileName, MS);
Inform Iwfileuploader that we are handling it ourselves. No need to save the file
SaveFile: = False;
Do whatever your want here with the TStream containing the file. For instance, save to the Clientdataset
With ClientDataSet1 do begin
Append;
Fieldbyname (' FileName '). Asstring: = FileName;
Fieldbyname (' FileSize '). Asinteger: = MS. Size;
Set to the start of the Stream
Ms. Position: = 0;
Save to the Blob field
Tblobfield (Fieldbyname (' filecontent ')). Loadfromstream (MS);
Post;
End
Finally
Release the Stream
Ms. Free;
End
End

Initialization
Tiwform7.setasmainform;

End.

Iwfileuploader official Demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.