Re: WebShop File Upload
Nejc R.
1-14-20
Hello,

This example is used with XHR for asynchronous upload.

The "start" part is just to receive the filename and create the file, setup session, setup loading bar on the webpage etc. It's just a normal ajax call to the server to make sure everything is set up.
$.get("/WebFileUpload.hal?action=start&session=" + session + "&newname=" + newname + "&filename=" + filename,function(data){...});

"file" is the only place where XHR is actually used. The way this is setup it can handle breaking up larger files and uploading them as parts
if you want the upload to actually work in blocks you need to handle breaking the file apart in JavaScript and send piece by piece with XHR, the server-side code will just append everything it gets to the file.
xhr.open('POST', "/WebFileUpload.hal?action=file&session=" + session + "&tmpname=" + tmpname +"&fn=" & fn, true);

"end" is also just a standard ajax call to finalize upload, move file to proper location, delete the temporary one and clean up the loading bar on the webpage.
$.get("/WebFileUpload.hal?action= end&session=" + session,function(data){...});


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
Is it something when a user tried to use any of AI commands in SERP? /Piotr W....
10:07 8 Nov 2024
Brittany McGrath
Thank you for your post Lilian. I see this post has been submitted twice and the second post is being addressed so I will close this duplicate. Thank you. ...
09:41 5 Nov 2024