This is a migrated thread and some comments may be shown as answers.

Setting New Filename Outside of _FileUploaded

2 Answers 83 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 29 Jul 2010, 10:08 AM
Hi,

I have a RadAsyncUpload control on my page used for a simple 'email' type functionality where a user can attach documents to a message. On button click to send the message my workflow is this...

  1. Save the message to a database and return the id of the message
  2. Save the recipients of the of the message using the id that is returned from the above function.
  3. I then save each attachment to the db passing in the message id and return the full path of where the file should be saved (looking like this : blah/foo/blah/de/blah/6F9619FF-8B86-D011-B42D-00C04FC964FF.pdf)

My problem is re-naming the file to the guid passed back as the from what i can see the _FileUploaded event (where i can perform this function) fires before my button click event.

Any ideas?

2 Answers, 1 is accepted

Sort by
0
Lenny_shp
Top achievements
Rank 2
answered on 29 Jul 2010, 02:43 PM
Your solution doesn't seem to work for more than 1 attachment.

In the postback (final submit) you can do something like this and don't need code in _FileUploaded:  (customize to fit your needs)

 For Each file As Telerik.Web.UI.UploadedFile In myUpload.UploadedFiles
                Dim strGUID As String
                strGUID = Guid.NewGuid.ToString
                Dim strOriginalFileName As String = file.GetName '.Replace("'", "").Replace("&", "and")
                Dim strFileGUIDName As String = strGUID & "_" & strOriginalFileName
                Dim strFileFullPath As String = Path.Combine(strUploadPath, strFileGUIDName)

                Using Hosting.HostingEnvironment.Impersonate
                    file.SaveAs(strFileFullPath, True)
                End Using
Next
0
David
Top achievements
Rank 1
answered on 29 Jul 2010, 04:50 PM

Tags
AsyncUpload
Asked by
David
Top achievements
Rank 1
Answers by
Lenny_shp
Top achievements
Rank 2
David
Top achievements
Rank 1
Share this question
or