File Upload in MySQL Database with ASP

Thread Solved

Join Date: May 2006
Posts: 4
Reputation: HemantK is an unknown quantity at this point 
Solved Threads: 0
HemantK's Avatar
HemantK HemantK is offline Offline
Newbie Poster

File Upload in MySQL Database with ASP

 
0
  #1
May 25th, 2006
Hi Everybody!

How to upload a image / pdf file in mysql table blob column with
ASP

pls help me

HemantK
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 24
Reputation: sosco is an unknown quantity at this point 
Solved Threads: 4
sosco's Avatar
sosco sosco is offline Offline
Newbie Poster

Re: File Upload in MySQL Database with ASP

 
0
  #2
May 28th, 2006
try this one, if i understand well what you want:

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public Sub Addfile(ByVal sender As Object, ByVal e As EventArgs)
UploadFile(1, "test", 123, "c:\myfile.jpg")
End Sub

Public Shared Sub UploadFile(ByVal file_id As Integer, ByVal file_name As String, ByVal file_size As Integer, ByVal file_path As String)

Dim Conn As Data.Odbc.OdbcConnection = New Data.Odbc.OdbcConnection("dsn=mydatabase")
Conn.Open()

Dim command As Data.Odbc.OdbcCommand = New Data.Odbc.OdbcCommand("INSERT INTO `files` set file_name=?, file_size=?, file=?")

Dim file() As Byte = GetFile(file_path)

command.Parameters.Add("?", Data.Odbc.OdbcType.VarChar).Value = file_name
command.Parameters.Add("?", Data.Odbc.OdbcType.Int).Value = file_size
command.Parameters.Add("?", Data.Odbc.OdbcType.Binary).Value = file
command.Connection = Conn
command.ExecuteNonQuery()

Conn.Close()
End Sub

Public Shared Function GetFile(ByVal file_Path As String) As Byte()
Dim stream As System.IO.FileStream = New System.IO.FileStream(file_Path, IO.FileMode.Open, IO.FileAccess.Read)
Dim reader As System.IO.BinaryReader = New System.IO.BinaryReader(stream)
Dim file() As Byte = reader.ReadBytes(stream.Length)
reader.Close()
stream.Close()
Return file
End Function

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="addfile"/>
</div>
</form>
</body>
</html>
---------------------------
Modest Valentin, Ticu
IATAR Studio

http://iatar.no-ip.org/
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 4
Reputation: HemantK is an unknown quantity at this point 
Solved Threads: 0
HemantK's Avatar
HemantK HemantK is offline Offline
Newbie Poster

Re: File Upload in MySQL Database with ASP

 
0
  #3
May 29th, 2006
Hi !

Thanks for quick reply and solution.

I have also worked out the problem on the same line

thanks once again

HemantK
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 24
Reputation: sosco is an unknown quantity at this point 
Solved Threads: 4
sosco's Avatar
sosco sosco is offline Offline
Newbie Poster

Re: File Upload in MySQL Database with ASP

 
0
  #4
May 29th, 2006
you are welcom
---------------------------
Modest Valentin, Ticu
IATAR Studio

http://iatar.no-ip.org/
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 24
Reputation: sosco is an unknown quantity at this point 
Solved Threads: 4
sosco's Avatar
sosco sosco is offline Offline
Newbie Poster

Re: File Upload in MySQL Database with ASP

 
0
  #5
May 29th, 2006
*welcome
---------------------------
Modest Valentin, Ticu
IATAR Studio

http://iatar.no-ip.org/
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: zhk is an unknown quantity at this point 
Solved Threads: 0
zhk zhk is offline Offline
Newbie Poster

Re: File Upload in MySQL Database with ASP

 
0
  #6
Dec 13th, 2007
Hi,

I am new to ASP and I am trying to upload .PDF files into MySQL. Can you please tell me if this can be applied to VBScript instead of VB? Or If you tell me how to make IIS to accept this VB Code. I do not have VB on my server.

Thanks
Zhk
Last edited by zhk; Dec 13th, 2007 at 10:53 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 6488 | Replies: 5
Thread Tools Search this Thread



Tag cloud for ASP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC