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
Piotr Wycichowski
Thanks Gatis, anyway it seems to be reported as bug instead of wish because now it depends on who created task for whom, am I right? /Piotr W....
14:39 15 May 2024
Aldevinas Katkus
Actually a new version of this bug is SL>>Reports>>Periodic customer statement "accumulates" amounts Not sure why it was duplicated, I clicked "submit"only once....
08:09 10 May 2024