problem with OnFileReceived

Feb 20, 2009 at 8:15 PM
i have a problem with the variables that i use on the event OnFileReceived i use this event cause when i upload the images to my server i have to save the name of the image on a database the problem is that when i save the variables on the db they are empty but on my code they are not empty so i think that when this event is fire your component some how cleans the variables that i grab from other pages


This is my code:

public var_user as string
public var_title as string
public var_album as string

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        user = Request.QueryString("User")                   'if i use get method doesnt work
        var_title = session("title")                                    'if i use session variables doesnt work either
        var_album = "album 1"                                                 'it only works if i write the string here in the code but if i use dynamic variables it doesnt

    End Sub

Protected Sub FileReceived(ByVal sender As Object, ByVal e As com.flajaxian.FileReceivedEventArgs)
        Dim i_user as string = var_user
        Dim img As Bitmap
        Dim id_user as string = var_title
        Dim i_category as string = DropDownList1.SelectedValue
        Dim i_album as string= var_album
        Dim i_title as String = "my picture"
        Dim i_image As String
        Dim rootimg = MapPath("~/fotos_fotos/")
        Dim rootimg1 = MapPath("~/fotos_temporales/")
        Dim num_aleat As Integer

        Randomize()
        num_aleat = Int(Rnd() * 10000)

        i_image = num_aleat & id_user & e.File.FileName
        e.File.SaveAs(rootimg1 & i_foto)
        img = System.Drawing.Image.FromFile(rootimg1 & i_foto)
        SaveJPGWithCompressionSetting(img, rootimg & "thumb" & i_foto, 50)
        img = Nothing
        Dim Conexion = Server.CreateObject("ADODB.connection")
        Conexion.open("Driver={MySQL ODBC 3.51 Driver};Server=XX.XXX.XXX.XX;Port=3306;Database=XXXX;Uid=XXXX;Pwd=XXXX;OPTION=3;")
        Dim sqlstr = "INSERT INTO `album` (`user` , `img_name` , `category` , `title` , `album` ) VALUES ('" & i_user & "', '" & i_image & "', '" & i_category & " ', '" & i_title & "', '" & i_album & "');"
        Conexion.execute(sqlstr)
        Conexion.close()

    End Sub

so my table would look like this:
user = nothing
img_name = name of the image
category = selected category
title = nothing
album = album 1




if somebody could help me with this i would really appreciated

Coordinator
Feb 20, 2009 at 11:15 PM
1. If you want to pass variable to the server you do it this way: http://www.flajaxian.com/flajaxian.com/FileUploader2.0Help.html#HowToSendVars
2. If the session doesn't work that means you haven't done this: http://www.flajaxian.com/flajaxian.com/FileUploader2.0Help.html#HowToOvercomeFlashBug
Read the help file.
Feb 23, 2009 at 6:13 PM
im sorry to bother you again but i did what you tell me but nothing happend its all the same i have never use the global.asax file so maybe thats where i have the problem i try to put the code thats on your help file on a global.asax thati created but my code its on VB this is my code if you could tell me if its fine

<%@ Application Language="VB" %>

<script runat="server">
    Public Overloads Sub Init(ByVal application As HttpApplication)
        MyBase.Init()
        AddHandler application.OBeginRequest, AddressOf OnBeginRequest
    End Sub
    
    Public Sub OnBeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        com.flajaxian.FileUploader.RegisterAspCookies()
    End Sub


    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
    End Sub
    
    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application shutdown
    End Sub
        
    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when an unhandled error occurs
    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a new session is started
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a session ends.
        ' Note: The Session_End event is raised only when the sessionstate mode
        ' is set to InProc in the Web.config file. If session mode is set to StateServer
        ' or SQLServer, the event is not raised.
    End Sub
       
</script>