我正在使用 AsyncFileUpload 上传文件,在将文件保存在服务器上之前,我重命名了所选文件。如何在客户端获取这个新文件名?
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
OnUploadedComplete ="UploadFile1"
OnClientUploadComplete="uploadComplete" ThrobberID="myThrobber" />
客户端脚本:
<script>
function uploadComplete(sender, args) {
var fileExtension = args.get_fileName();
}
</script>
服务器端脚本:
Protected Sub UploadFile1(ByVal sender As Object, ByVal e As System.EventArgs)
Dim fileuploadreceive1 As String = AsyncFileUpload1.PostedFile.FileName
Dim strExtn As String = System.IO.Path.GetExtension(fileuploadreceive1).ToLower
Dim filename1 As String = Path.GetFileName(fileuploadreceive1)
filename1 = "uld" & Math.Round(Rnd() * 2366) & filename1 'changing original file name
Dim fileuploadpath1 As String = Server.MapPath("~") & "\gallery\"
If (strExtn = ".png") Or (strExtn = ".jpg") Or (strExtn = ".gif") Then
AsyncFileUpload1.PostedFile.SaveAs(Path.Combine(fileuploadpath1, filename1))
End If
End Sub