Multiple file upload and FileUploaded event

8 posts, 0 answers
  1. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 26 Jul 2010 Link to this post

    2010.2.722.35  VS2008 IE8

    When I select 2 files for multiple upload and the transfer is completed, if a postback happens it seems FileUploaded are being called once per file, over and over again for each ajaxified postback.  

    Shouldn't FileUploaded only be fired once per file?    Otherwise if e.file.saveas is called, subsequent call would have failed.



  2. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 26 Jul 2010 Link to this post

    Never mind, I did not have to use FileUploaded event at all.   It was causing more trouble when I used it.
    I used the same code that I had for the regular RadUpload on the final submit and that worked fine.

    For Each file As Telerik.Web.UI.UploadedFile In myUpload.UploadedFiles
  3. Sathish
    Sathish avatar
    15 posts
    Member since:
    Dec 2010

    Posted 06 Apr 2011 Link to this post

    Any work around for this behavior?

    I want to save the file to the db, but i dont want to use handler. the file uploaded event is being called everytime for every single file.

    for example,

    if i upload 1 file, the fileuploaded event is called once
    for the second file, the fileuploaded event is called TWICE

    what i want to do is to save the file to the db as soon as its uploaded. since this is firing many times, it is creating duplicate entries. i tried to get the hashcode and store in viewstate, did not work, tried session variables and check if its already processed, somehow its not working.

    could you please tell me how to work around this?

    Thanks
  4. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 08 Apr 2011 Link to this post

    Hello Sathish,

    When file(s) are uploaded, the OnFileUploaded server side event is fired for every file. The file is stored into a temporary folder with a unique name.
    After a postback, if a TargetFolder property is set, the file is moved with it's real name into the TargetFolder.
    Otherwise the file stays into a temporary folder.
    Using the UploadedFile property of the FileUploadedEventArgs object into the OnFileUploaded event handler you get a reference to the uploaded file.
    For additional information please review the following help article.

    Kind regards,
    Peter Filipov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Sathish
    Sathish avatar
    15 posts
    Member since:
    Dec 2010

    Posted 08 Apr 2011 Link to this post

    I understand that and I can see that happening. But if I have already processed a file, how do I remember that the file has been processed? And the temp file path is a protected member and therefore I am not able to call it from my user control.
  6. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 12 Apr 2011 Link to this post

    Hi Sathish,

    The uploaded files are stored with their unique names into the TemporaryFolder. You can get the file name form the event arguments in the OnFileUploaded handler(e.g. args.File.InputStream.FileName).
    You may store it into a HashTable later.

    To get the temporary folder name from the control you may use the following:
    RadAsyncUpload1.TemporaryFolder

    Kind regards,
    Peter Filipov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Rohan
    Rohan avatar
    94 posts
    Member since:
    Jul 2012

    Posted 15 Jun 2012 Link to this post

    Hi all ,

    I am using rad RadUpload to upload the file. I want upload one file to multiple location . i am using the stream to upload the file  and function  is ----

     public int StreamFile(UploadedFile file,string path)
            {
                long _tlenght = 0;
                _tlenght = file.InputStream.Seek(0, SeekOrigin.Begin);

                try
                {
                      using (Stream _fileStream = file.InputStream)
                    {
                        long _fileL = _fileStream.Length;
                        string _fileName = Path.GetFileName(file.FileName);
                        byte[] _streamBytes = new byte[2048];
                        _fileStream.Read(_streamBytes, 0, _streamBytes.Length);
                        long _totalLength = 0;
                        int _toBeRead = 0;
                        _totalLength = _fileStream.Length;
                        _toBeRead = 0;
                        _tlenght = _fileStream.Length;
                        using (FileStream _inFileStream = File.Create(HttpContext.Current.Server.MapPath("~//Portals/" + path + file.GetName())))
                        {
                            long temp1 = 0;
                            while (_tlenght > 0)
                            {
                                _inFileStream.Write(_streamBytes, 0, _streamBytes.Length);
                                _tlenght = _fileStream.Read(_streamBytes, 0, _streamBytes.Length);
                                temp1 = temp1 + _streamBytes.Length;
                            }

                        }
                        return 1;
                    }
                }
                catch (Exception _error)
                {
                    return -1;
                }
     
            }

    -------
    Using this function i upload file to only one location with uploaded file size after that this function create file to renaming location but file size is 0 it only creates file with specified name..... how can i do this ......
  8. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 20 Jun 2012 Link to this post

    Hello Rohan,

    In order to avoid inconsistency of the thread, please open a new support ticket and send me your sample project to investigate it locally. Also please clarify what do you mean by "function create file to renaming location but file size is 0 it only creates file with specified name..... how can i do this".

    Regards,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top