Hi, Lee,
So this part WebFileUpload.hal?action=doupload you can see in the procedure WebFileUpload.
The DoUploadChuck is roughly like this(it's not actual code and won't work, it's just to look at roughly how it works. Hope it helps)
global
function Boolean webup(var string filename,var area rfilearea)
begin
Area FileArea,img,FADone,nFileArea;
Longint enter;
Longint lcnt,pos,spos,epos,pepos;
string 255 tstr,namestr;
boolean getnamef;
Longint namepos,nameepos,i;
string 255 link;
boolean savef;
getnamef = false;
namepos = 0;
nameepos = 0;
savef = true;
WebGetRawPostData(rFileArea);
//ReplaceWebStrings(nFileArea,rfilearea);
savef = true;
webup = savef;
return;
end;
global
updating procedure chunkup(string sess,string fn,var string nename)
begin
CreateFolder("tmp/" & sess);
CreateFile("tmp/" & sess & "/" & fn & ".tmp");
nename = fn & ".tmp";
return;
end;
global
updating procedure chunkupchunk(string sess,string fn,var area tarea)
begin
AppendAreaToFile("tmp/" & sess & "/" & fn,tarea);
return;
end;
global
updating procedure chunkupfinish(string sess,string tmpname,string fn)
begin
string 255 folder;
folder = "tmp/" & sess;
RenameFile(folder & "/" & tmpname,folder & "/" & fn);
return;
end;
global
procedure HandleFileUploadFinish(string sess)
begin
string 255 path,filename,id,tag;
switch (tag) begin
case "test":
if (FileExists("tmp/" & tag & "/" & sess)) then begin
RenameFile("tmp/" & tag & "/" & sess,"tmp/" & tag & "/" & filename);
end;
end;
path = "tmp/" & tag & "/" & sess;
if (FileExists(path)) then begin
Delete_File(path);
end;
return;
end;
global
procedure WebDoUploadChunk()
begin
string 255 filename,foldername,tname;
String 255 server_uuid,server_addr,server_port,country,product,localizations;
Integer oldcomp,cc;
area tarea;
record CUVc CUr;
BOolean succf;
switch (WebGetArg("type")) begin
case "start":
qupdating.chunkup(GetWebSessionUUID,WebGetArg("filename"),filename);
PutSessionString("temp_upload_filename",filename);
PutSessionString("temp_upload_filename2",WebGetArg("filename"));
case "file":
webup(tname,tarea);
qupdating.chunkupchunk(GetWebSessionUUID,GetSessionString("temp_upload_filename"),tarea);
case "end":
qupdating.chunkupfinish(GetWebSessionUUID,GetSessionString("temp_upload_filename"),GetSessionString("temp_upload_filename2"));
product = "test";
foldername = "tmp/" & GetWebSessionUUID;
WebOutString("");
end;
return;
end;