Re: WebShop File Upload
Edgars Dzenis
1-9-20
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;
Leave Comment
You can subscribe to notifications for this post by selecting the 'star' icon on the top right corner of the post.
Latest Posts
David Delač
Hi Gastón, Please report a bug in our issue tracker and attach test database that you can repeat this in so I can have a look. Paste subject here once done...
09:46 14 May 2025
Paul Timms
From what I've read, using these will store the updated records in memory and then write them to the database in bulk, instead of each record writing to the database in turn. So perhaps there&apo...
17:53 29 Apr 2025