Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var auth = "<%= IIf(IsNothing(Request.Cookies(FormsAuthentication.FormsCookieName)),String.Empty,Request.Cookies(FormsAuthentication.FormsCookieName).Value) %>";
- var ASPSESSID = "<%=Session.SessionID%>";
- $(window).load(
- function () {
- alert(auth);
- $("#FileUpload1").fileUpload({
- 'uploader': 'scripts/uploader.swf',
- 'cancelImg': 'image/cancel.png',
- 'buttonText': 'Click to Choose Document',
- 'script': 'UploadDocument.aspx',
- //'scriptData': { 'ASPSESSID': ASPSESSID, 'AUTHID': auth },
- 'scriptData': { 'token': auth },
- 'folder': 'Documents',
- 'hideButton': false,
- //'wmode': 'transparent',
- 'multi': true,
- 'auto': false
- });
- }
- );
- </script>
- Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
- ' Fires at the beginning of each request
- Try
- Dim session_param_name = "ASPSESSID"
- Dim session_cookie_name = "ASP.NET_SessionId"
- If Not HttpContext.Current.Request.Form(session_param_name) Is Nothing Then
- UpdateCookie(session_cookie_name, HttpContext.Current.Request.Form(session_param_name))
- ElseIf Not HttpContext.Current.Request.QueryString(session_param_name) Is Nothing Then
- UpdateCookie(session_cookie_name, HttpContext.Current.Request.QueryString(session_param_name))
- End If
- Catch ex As Exception
- End Try
- Try
- Dim auth_param_name = "AUTHID"
- Dim auth_cookie_name = FormsAuthentication.FormsCookieName
- If Not HttpContext.Current.Request.Form(auth_param_name) Is Nothing Then
- UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form(auth_param_name))
- ElseIf Not HttpContext.Current.Request.QueryString(auth_param_name) Is Nothing Then
- UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString(auth_param_name))
- End If
- Catch ex As Exception
- End Try
- End Sub
- Context.Response.ContentType = "text/plain"
- Context.Response.Expires = -1
- Dim token As String = Context.Request.Params("token")
- 'Dim token As String
- 'If IsNothing(Request.Cookies(FormsAuthentication.FormsCookieName)) Then
- ' token = String.Empty
- 'Else
- ' token = Request.Cookies(FormsAuthentication.FormsCookieName).Value
- 'End If
- Dim ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(token)
- If ticket IsNot Nothing Then
- Dim identity = New FormsIdentity(ticket)
- If identity.IsAuthenticated Then
- Try
- Dim postedFile As HttpPostedFile = Context.Request.Files("")
- Dim tempStr As String = Context.Request.QueryString("")
- Dim savepath As String = ""
- Dim tempPath As String = ""
- tempPath = System.Configuration.ConfigurationManager.AppSettings("FolderPath")
- savepath = Context.Server.MapPath(tempPath)
- Dim filename As String = postedFile.FileName
- Dim filetype As String = postedFile.ContentType
- If Not Directory.Exists(savepath) Then
- Directory.CreateDirectory(savepath)
- End If
- postedFile.SaveAs(savepath & "" & filename)
- Context.Response.Write(savepath & "" & filename)
- Context.Response.StatusCode = 200
- Catch ex As Exception
- Context.Response.Write("Error: " & ex.Message)
- End Try
- End If
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement