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
Carolina Valentino
are the activity set as Hansamanuals said? https://www.hansamanuals.com/main/mailnumber___62526/theconf___231/manuals/version___20250224/langcode___es/hwconvindex.htm?shortcode=HW0301SETTINGS_Order...
17:20 4 Apr 2025
Paul Timms
SendWebRequest3 is a boolean function, so if this returns true and the reply header has an accepted status, you can assume that the data was sent successfully and perform some actions on the record th...
11:12 4 Apr 2025