Forced accept.
Computer101
EE Admin
Main Topics
Browse All TopicsHi,
1.
Why in the page when I click right button and want to try save an image I have the following message:
"The file type being save or retrieved has been blocked."
2.
How can I save images from web using VB.NET ?
I get images as:
<asp:Image ID="Image1" runat="server" ImageUrl='<%# FormatURL(DataBinder.Eval(
Function FormatURL(ByVal strArgument) As String
Return ("readrealimage2.aspx?id="
End Function
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ODB
<HTML>
<HEAD>
<title>Read Record</title>
<script runat="server">
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim strImageID As String = Request.QueryString("id")
' Create Instance of Connection and Command Object
Dim myConnection As OdbcConnection = New OdbcConnection(Configurati
' Mark the Command as a SPROC
Dim cmdStr As String = "select * from bmmsfile WHERE fileid=" & strImageID
Dim myCommand As OdbcCommand = New OdbcCommand(cmdStr, myConnection)
Dim _image, _newimage As System.Drawing.Image
mycommand.CommandType = CommandType.Text
Try
myConnection.Open()
Dim myDataReader As OdbcDataReader
myDataReader = myCommand.ExecuteReader(Co
Do While (myDataReader.Read())
Response.ContentType = myDataReader.Item("fileid"
Dim bindata() As Byte = myDataReader.Item("data")
Dim Thumbnailbindata() As Byte = resizeImage(bindata)
Response.BinaryWrite(Thumb
Loop
myConnection.Close()
Catch SQLexc As OdbcException
Response.Write("Error occured while Generating Data. Error is " & SQLexc.ToString())
End Try
End Sub
Public Function resizeImage(ByVal pic() As Byte) As Byte()
' Const THUMBNAIL_IMAGE_PATH As String = "C:\Thumbnails\Test.jpg"
Const maxWidth As Integer = 500
Const maxHeight As Integer = 500
Dim inp As New IntPtr
Dim imgHeight, imgWidth As Double
Try
Dim image As System.Drawing.Image = System.Drawing.Image.FromS
Dim bm = New System.Drawing.Bitmap(imag
Dim imgHres, imgVres As Single
'Added this for testing - usually 96 dpi for every picture
imgHres = bm.horizontalresolution
imgVres = bm.verticalresolution
imgHeight = bm.Height
imgWidth = bm.Width
If imgWidth > maxWidth Or imgHeight > maxHeight Then
'Determine what dimension is off by more
Dim deltaWidth As Double = imgWidth - maxWidth
Dim deltaHeight As Double = imgHeight - maxHeight
Dim scaleFactor As Double
If deltaHeight > deltaWidth Then
'Scale by the height
scaleFactor = maxHeight / imgHeight
Else
'Scale by the Width
scaleFactor = maxWidth / imgWidth
End If
imgWidth *= scaleFactor
imgHeight *= scaleFactor
End If
Dim w As Integer = Convert.ToInt32(imgWidth)
Dim h As Integer = Convert.ToInt32(imgHeight)
Dim imgbmp As System.Drawing.Image = bm.GetThumbnailImage(w, h, Nothing, inp)
Dim ms As New System.IO.MemoryStream
imgbmp.Save(ms, System.Drawing.Imaging.Ima
Dim b(ms.Length - 1) As Byte
ms.Position = 0
ms.Read(b, 0, ms.Length)
Return b
'bitmap.Save(THUMBNAIL_IMA
Catch ex As Exception
End Try
End Function 'resizeImage
Public Function ConvertTo(ByVal ImageArray As Byte()) As System.Drawing.Image
'<summary>
' Convert a SQL Server database byte Array (byte array) to a Image.
'</summary>
Dim objMS As System.IO.MemoryStream
Dim objImage As System.Drawing.Image
objMS = New System.IO.MemoryStream(Ima
' Convert the database byte array to a System Drawing Image.
ConvertTo = System.Drawing.Image.FromS
End Function
</script>
</HEAD>
<body style="font: 10pt verdana">
<form runat="server" id="Form1">
</form>
</body>
</HTML>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: stevekorbPosted on 2007-06-28 at 09:03:25ID: 19382041
It is possible using javascript to block any attempts at downloading images or code from a page. Perhaps the site you are accessing has done just that.