Additional process after upload

Last post 02-25-2009, 1:53 AM by cutechat. 6 replies.
Sort Posts: Previous Next
  •  02-23-2009, 6:11 PM 49142

    Additional process after upload

    Hi All,
     
    Is this possible?

        protected void InputFile_FileUploaded(object sender, UploaderEventArgs args)
        {
            //upload files into a temp folder
            //get path/filename of file from temp folder
            //insert some code-behind checking/validation using that path/filename
     
            //if true then
           //    copy file from temp folder to upload folder and use that path/filename
            //else
           //    delete file from temp folder then alert user of error
     }
     
    I'm not sure if this event is the correct one to use, would appreciate if someone could help me out.
     
    Thanks!
     
     
  •  02-24-2009, 8:31 PM 49205 in reply to 49142

    Re: Additional process after upload

    Hi,

    Please use the FileValidating event.
     
    just use args to get the file information,
     
    throw an exception if you want to show an alert.
     
    Regards,
    Terry
  •  02-24-2009, 11:03 PM 49208 in reply to 49205

    Re: Additional process after upload

    Thanks!
     
    The FileValidating event triggers before the file is uploaded on the server. (client-side)
     
    This prevents us from validating the file (server-side) after the file is uploaded.
     
    Is there another way to do this?
  •  02-25-2009, 12:02 AM 49210 in reply to 49208

    Re: Additional process after upload

    Hi,
     
    When the FileValidating be fired, the file data have been uploaded completely.
     
    You can validate the file data and do something there.
     
    The difference between FileValidating and FileUploaded,
     
    Is that FileValidating is in another page life cycle and any UI changes would not take effects.
     
    ----
     
    In the FileValidating or FileUploaded,
     
    You can use the argument 'args' to get the temp path of the file, and you can also get the filename.

    Regards,
    Terry
  •  02-25-2009, 12:22 AM 49211 in reply to 49210

    Re: Additional process after upload

    thanks cutechat for clearing this up.
     
    :)
  •  02-25-2009, 1:00 AM 49212 in reply to 49211

    Re: Additional process after upload

    Hi cutechat,
     
    Here's the code I've been working on
     
     protected void InputFile_FileValidating(object sender, UploaderEventArgs args)
        {

         
            DSOFile.OleDocumentProperties oleDocument = new DSOFile.OleDocumentProperties();
            DSOFile.SummaryProperties summaryProperties = default(DSOFile.SummaryProperties);
            string postedfile = "C:\\backups\\Projects\\CMS\\Uploads\\" + args.FileName.ToString();

            oleDocument.Open(postedfile, true, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);

            summaryProperties = oleDocument.SummaryProperties;
            if (string.IsNullOrEmpty(summaryProperties.Title) | string.IsNullOrEmpty(summaryProperties.Author))
            {
           
                args.Delete();
                throw new ArgumentException("No Properties Found");
            }
            else
            {

            }

            oleDocument.Close(false);
        }

    I got an error that says "The name is not valid". I think that the file is not yet on the "Upload" folder. Any help is appreciated :)
  •  02-25-2009, 1:53 AM 49214 in reply to 49212

    Re: Additional process after upload

    Hi,
     
    While the file uploading , the file is in another location.
     
    You can use
     
    string fullpath=args.GetTempFilePath();
     
    to get it.
     
    Regards,
    Terry
View as RSS news feed in XML