How to know when the file was loaded 100%

Asked

Viewed 75 times

0

I have a feature that does the following:

  1. Load a video from the user’s PC using C#
  2. Put the video link in src of an HTML5 using Jquery

The problem:

It puts the link and shows the player, but as the video has not yet uploaded the 100% does not appear anything in the player. After a few seconds, if you press play, it starts smoothly.

I keep the video like this:

private void UploadWholeFile(HttpContext context, List<FilesStatus> statuses, 
                              string pre_hash = "")
    {
        for (int i = 0; i < context.Request.Files.Count; i++)
        {
            var file = context.Request.Files[i];

            var fullPath = StorageRoot + pre_hash + Path.GetFileName(file.FileName);


            file.SaveAs(fullPath); // <---- GUARDO AQUI <---------------

            string fullName = Path.GetFileName(file.FileName);
            statuses.Add(new FilesStatus(pre_hash + fullName, file.ContentLength, 
                                          fullPath));
        }
    }

How can I know when the file was loaded (this save function N different files, in the context of this problem always comes only one item to the loop)?

  • Hello @ihavenokia, you could add the full code?

  • i just want to know when that code, which I posted, completely loads a file. Like an event or so I can use in javascript

  • That’s why I asked for your code. How are you uploading? Are you uploaded to the server by Ajax? Using a POST? Without more information it is not possible to help you

  • I don’t currently have access to the code, but upload using a C# method that stores the file in the filePath and saves the path in the database. I search this link in jQuery using Ajax. the problem is that the link in the initial instants points to an incomplete file(?)

  • In this case, Voce should only write to the base when its file has been uploaded. even because, if there is interruption in the middle of the upload, you will be with something written in the base that does not exist in your filesystem, breaking your application

  • the doubt remains equal haha how can I know if the upload process has been completed.

  • I’ve already added more code

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.