1
我在使用AsyncFileUpload上傳文件之前,先保存服務器上的文件,然後重命名所選文件。我怎樣才能在客戶端獲得這個新的文件名?如何在客戶端使用AsyncFileUpload獲取serverside文件名
<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
我在說'args.get_fileName();'它返回原來的'filename1' – Maysam