tbl_extension
<table border="1" width="80%><br" mode="hold" /> <tr>
<td>ID</td>
<td>extension</td>
<td>Class</td>
</tr>
<tr>
<td>1</td>
<td>.jpg</td>
<td>image</td>
</tr>
<tr>
<td>2</td>
<td>.png</td>
<td>image</td>
</tr>
<tr>
<td>3</td>
<td>.gif</td>
<td>image</td>
</tr>
<tr>
<td>4</td>
<td>.bmp</td>
<td>image</td>
</tr>
<tr>
<td>5</td>
<td>.avi</td>
<td>video</td>
</tr>
<tr>
<td>6</td>
<td>.mp4</td>
<td>video</td>
</tr>
<tr>
<td>7</td>
<td>.mp3</td>
<td>audio</td>
</tr>
<tr>
<td>8</td>
<td>.wma</td>
<td>audio</td>
</tr>
</table>
Default.aspx
DropDownList:
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>image</asp:ListItem>
<asp:ListItem>video</asp:ListItem>
<asp:ListItem>audio</asp:ListItem>
</asp:DrpDownList>
file upload :
<asp:FileUpload ID="FileUpload1" runat="server" />
Upload Button :
<asp:Button ID="Button1" runat="server" Text="Upload" />
Default.aspx.vb
notice:I also created a connection to DataBase with a vb class page.
I uploaded an image(1.jpg) but this code isn't working...
con.connecton()
con.query("select * from tbl_extension where Class='" & DropDownList1.SelectedItem.ToString & "' ")
While con.Reader.Read()
If FileUpload1.FileName Like "*" & con.Reader("extension").toString then
FileUpload1.PostedFile.SaveAs("c:\test\")
EndIf
End While
con.Reader.Close()
notice:in this example i select the same image but it is woking normaly !!!.
If FileUpload1.FileName Like "*.jpg" then
FileUpload1.PostedFile.SaveAs("c:\test\")
EndIf