Is there a way to continue working with the website while the file is loading?

Background:

I am working on a design project for my CS department. The project is a website for the biology department, and a key feature is that biology students can upload their own .xml , and then a * model is created for them on the server side using Matlab.

The external interface is in ASP.NET, javascript, and C #. My little connection with this project is all the knowledge that I have in these systems, tools and languages.

Question:

The .xml I mentioned earlier can take hours to download and build. My professor wants the user to be able to continue working with the page using models that are already completed when the new model is sent to the background, and the user receives an email at the end. I found material to send email, but not to continue the page.

Did I hear something about using AJAX to load a page?

+4
source share
4 answers

Put a download control on your page

 <asp:FileUpload ID="FileUpload1" runat="server"/> 

Create an http handler to handle file upload:

 public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { HttpPostedFile fileToUpload = context.Request.Files["Filedata"]; string pathToSave = HttpContext.Current.Server.MapPath("~/Files/") + fileToUpload.FileName; fileToUpload.SaveAs(pathToSave); //Process file } public bool IsReusable { get { return false; } } } 

Take a look if you can integrate the plugin for upload, for example uploadify into a project (jQuery required).

 <script type = "text/javascript"> $(document).ready(function() { $("#<%=FileUpload1.ClientID %>").uploadify( { 'swf': 'Scripts/uploadify.swf', 'uploader': 'Handler.ashx', 'auto': true, 'buttonText': 'Select File(s)' }); }); </script> 

If you cannot do this, you need to understand how ajax works

Ajax usually uses XMLHttpRequest, which does not allow you to encode and send local files to the server.
You can use Flash swf to handle loading on the same page or use a form that has the goal of an invisible iframe 1x1.

I found the code posted on this blog post about uploading files to asp.net

+1
source

I think that when you open a small i-frame that actually does the loading, your current page will continue to work.

So, on your current page, you ask for the file location and file name and that's it, and then open a new page in the i-frame. Let this i-frame know the source file / folder, file / destination folder and let it work in the background. Now your current page can continue its work.

Hope this helps.

0
source

Use the mute Java Upload Applet. Download the file transfer applet to iFrame, let the user initiate the file transfer, and when the user wants to view the rest of the website, just don’t restart the iFrame containing the Java applet (which will load the file). After the transfer is complete, execute a JAvaScript call to close the iframe.

The following example uses the FileCatalyst Java applet, but the idea will be with almost any other Java or ActiveX Java applet

 <script> var browsePath = ""; function browseAndAdd() { browsePath = document.FileCatalyst.browseLive(true); } function upload() { document.FileCatalyst.uploadLive(); } function clearQueue() { document.FileCatalyst.clearQueue(); } </script> <!--Uses onClick for demonstration only--> <form id="uploadform"> <!--Launch a browse dialog and add the selected file to the queue--> <input type=button onClick="javascript:browseAndAdd();" value="Browse and Add to Queue" /> <!-- Force upload of whatever is currently found in the transfer queue --> <input type=button onClick="javascript:upload();" value="Upload"> <!-- Clear transfer queue (can be called only if no transfers are in progress) --> <input type=button onClick="javascript:clearQueue();" value="Clear Queue"> </form> 

Sorry for the lack of indentation, I find stackoverflow markup to insert jokes of code that are not very user friendly.

0
source

Ideally, you need to configure someinind asynchronous processing. Personally, I like to use Celery and RabbitMQ for my asynchronous messaging.

-1
source

Source: https://habr.com/ru/post/1440679/


All Articles