Results 1 to 2 of 2

Thread: uploading BLOB to database

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Question uploading BLOB to database

    looking to upload a PDF document from a clients pc to a Oracle database using ASP.NET...does anyone have some sample code or a link to a tutorial?

    thanks,
    eye

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    here is some sample upload code

    Code:
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Drawing" %>
    <%@ Import Namespace="System.Drawing.Drawing2D" %>
    <%@ Import Namespace="System.Drawing.Imaging" %>
    
    <HTML>
    	<script language="VB" runat="server">
    
        		Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
    			System.IO.File.Delete(Server.Mappath("Uploads\temp2.ful"))
    		End Sub
        		
    		Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    			' Get a stream of data of the selected file.
    			Dim s As System.IO.Stream = File1.PostedFile.InputStream
    			Dim data(File1.PostedFile.ContentLength - 1) As Byte
    			s.Read(data, 0, File1.PostedFile.ContentLength)
    			' Create file on the server
    			Dim fs As System.IO.FileStream = New System.IO.Filestream(Server.Mappath("Uploads\temp.ful"), System.IO.FileMode.Create, System.IO.FileAccess.Write)
    			fs.Write(data, 0, File1.PostedFile.ContentLength - 1)
    			fs.Close()
    			s.Close()
    			
    			' Open the file on the server and convert to Gif.
    			Dim newBitmap As Bitmap = New Bitmap(Server.Mappath("Uploads\temp.ful"))
    			newBitmap.Save(Server.Mappath("Uploads\temp2.ful"), ImageFormat.Gif)
    			newBitmap.Dispose()
    			
    			' Set the Image control to path of the final image.
    			finalImage.ImageURL = "Uploads\temp2.ful" 
    			
    		End Sub
    	</script>
    	<HEAD>
    		<title>Image Converter</title>
    	</HEAD>
    	<body>
    		<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
    			<asp:Label id="Label1" runat="server">Select A non-GIF Image to upload and convert to GIF :</asp:Label><br/>
    			<INPUT type="file" id="File1" name="File1" runat="server">
    
    			<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Upload"></asp:Button>
    			<asp:Image id="finalimage" runat="server"/>
    		</form>
    	</body>
    </HTML>
    you will need to adapt that of course. And someone else will need to help on adding the file to oracle.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width