How to validate a file name across record set?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khanooo
    New Member
    • Dec 2012
    • 1

    How to validate a file name across record set?

    Hi,

    I am working on a file uploader. Everything is working as intended, however I need to do some file validation on it across a database.

    I got the database to open the connection and get the values in a recordset, however I cannot take the filename that I choose to upload to find the name against the recordset.

    Code:
            function CuteWebUI_AjaxUploader_OnSelect(files) {
                    <%
                    Set AdoCon=Server.CreateObject("ADODB.Connection")
                    Set AdoRec=Server.CreateObject("ADODB.Recordset")
                    AdoCon.ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=******;Initial Catalog=AFDDB_DEVY;Data Source=MOMENTUMTEST"
                    AdoCon.Open
                    AdoRec.Open "Select Custid from APPLICATION",AdoCon
                    str=AdoRec.GetString()
                    %>
                   
                    for (var i = 0; i < files.length; i++) { 
                    var name = files[i].FileName; 
                    if (str!=name) { 
                        files[i].Cancel();
                        } 
                    }  
                    
                    <%
                    AdoRec.close
                    AdoCon.close
                    set AdoRec = Nothing
                    set AdoCon = Nothing
                    %>        
                }

    Can someone help me how to validate the file name that the user chooses against the recordset?

    Thanks,
    Khan
    Last edited by Rabbit; Dec 19 '12, 07:34 PM. Reason: Please use code tags when posting code.
  • sharmajv
    New Member
    • Apr 2013
    • 11

    #2
    Use this Function

    Code:
    public function getFileVal()
        dim files, file_name, array_path
        file_name = "This Is The Path Recieved When User Uploads"
        array_path = split(file_name,"\")
        file_name = array_path(ubound(array_path)) 'Here You Are Reading File Name
        getFileVal = file_name ' Here We Get The File Name From Path
    end function
    Loop this Using While and Compare getFileVal and Your File Name From RecordSet

    Comment

    Working...