473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to select an image for display in aspx

Hi All,

Can anyone help me out with this one. I have a basic aspx page with an image placeholder on it. I want to be able to click a button on the page and have a dialog window appear where I can navigate the Client's PC and select a file (a JPG of GIF). I then want to change the image placeholder to display the selected image.

The problem I have is that I just can't work out how to browse the clients hard-disk. I have tried "
commonDialog1 = CreateObject("UserAccounts.CommonDialog")" and

"MyFolder = New System.Windows.Forms.FolderBrowserDialog"

but both give me a dialog window 'ghost' that is, the appear as a frame without any contents. The only way I know they are there is if I drag another application window over them. The screen tries to redraw them without any luck.

TIA,

Peter Wallington

Oct 31 '05 #1
2 1814
I would think you would have to use an html file upload input control. (You cannot create common dialog boxs on a web app). You should be able to grab the selected filename from it???

<INPUT id="File1" type="file" name="fileInput" runat="server">

pseduo code to upload a file, modify accordingly:

If Not File1.PostedFile Is Nothing AndAlso Not File1.PostedFile.FileName = String.Empty Then
Try

fileName = Server.MapPath("~\uploads\") & Path.GetFileName(File1.PostedFile.FileName.ToStrin g)

File1.PostedFile.SaveAs(fileName)

fileSize = CType(File1.PostedFile.InputStream.Length, Integer)
contentType = File1.PostedFile.ContentType()

Dim fs As FileStream = New FileStream(fileName, FileMode.Open, FileAccess.Read)

imagefile = New Byte(CType(fs.Length, Integer)) {}

fs.Read(imagefile, 0, CType(fs.Length, Integer))

fs.Close()

FileFound = True

Catch ex As System.IO.FileNotFoundException

Trace.Warn("file not found", ex.ToString)


Catch ex As Exception

Trace.Warn("upload", ex.ToString)

End Try
End If

HTH,
Greg

"Peter Wallington" <ne**@paradigm-it.com.au> wrote in message news:43***********************@per-qv1-newsreader-01.iinet.net.au...
Hi All,

Can anyone help me out with this one. I have a basic aspx page with an image placeholder on it. I want to be able to click a button on the page and have a dialog window appear where I can navigate the Client's PC and select a file (a JPG of GIF). I then want to change the image placeholder to display the selected image.

The problem I have is that I just can't work out how to browse the clients hard-disk. I have tried "
commonDialog1 = CreateObject("UserAccounts.CommonDialog")" and

"MyFolder = New System.Windows.Forms.FolderBrowserDialog"

but both give me a dialog window 'ghost' that is, the appear as a frame without any contents. The only way I know they are there is if I drag another application window over them. The screen tries to redraw them without any luck.

TIA,

Peter Wallington

Oct 31 '05 #2
You forgot one. <roll eyes>

microsoft.public.dotnet.framework.aspnet
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message news:u1****************@TK2MSFTNGP09.phx.gbl...
I would think you would have to use an html file upload input control. (You cannot create common dialog boxs on a web app). You should be able to grab the selected filename from it???

<INPUT id="File1" type="file" name="fileInput" runat="server">

pseduo code to upload a file, modify accordingly:

If Not File1.PostedFile Is Nothing AndAlso Not File1.PostedFile.FileName = String.Empty Then
Try

fileName = Server.MapPath("~\uploads\") & Path.GetFileName(File1.PostedFile.FileName.ToStrin g)

File1.PostedFile.SaveAs(fileName)

fileSize = CType(File1.PostedFile.InputStream.Length, Integer)
contentType = File1.PostedFile.ContentType()

Dim fs As FileStream = New FileStream(fileName, FileMode.Open, FileAccess.Read)

imagefile = New Byte(CType(fs.Length, Integer)) {}

fs.Read(imagefile, 0, CType(fs.Length, Integer))

fs.Close()

FileFound = True

Catch ex As System.IO.FileNotFoundException

Trace.Warn("file not found", ex.ToString)


Catch ex As Exception

Trace.Warn("upload", ex.ToString)

End Try
End If

HTH,
Greg

"Peter Wallington" <ne**@paradigm-it.com.au> wrote in message news:43***********************@per-qv1-newsreader-01.iinet.net.au...
Hi All,

Can anyone help me out with this one. I have a basic aspx page with an image placeholder on it. I want to be able to click a button on the page and have a dialog window appear where I can navigate the Client's PC and select a file (a JPG of GIF). I then want to change the image placeholder to display the selected image.

The problem I have is that I just can't work out how to browse the clients hard-disk. I have tried "
commonDialog1 = CreateObject("UserAccounts.CommonDialog")" and

"MyFolder = New System.Windows.Forms.FolderBrowserDialog"

but both give me a dialog window 'ghost' that is, the appear as a frame without any contents. The only way I know they are there is if I drag another application window over them. The screen tries to redraw them without any luck.

TIA,

Peter Wallington

Oct 31 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Popoxinhxan | last post by:
HI guy I am working on the web application that required to display the chart image on the page. The process is clicking the button and browser will popup another windows that displayed...
0
by: Satish Appasani | last post by:
Hi: I have a ASP.NET form with Web layout which I've achieved using panels. In one of the tab I have a File control to upload Images. When I put a file in the file control and move to another...
1
by: Stephen | last post by:
Hi, I am using an Access database (OLE Object) and storing Image as a bytes after streaming. I am able to read it back as a stream and display it on the browser using the following code:...
1
by: NH | last post by:
Hi, I'm struggling to display an image on asp.net webform (vb.net). The image is stored in a image field in a sql server database. I have read a good few solutions to it and still havnt got it...
2
by: Peter Wallington | last post by:
Hi All, Can anyone help me out with this one. I have a basic aspx page with an image placeholder on it. I want to be able to click a button on the page and have a dialog window appear where I can...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
4
by: MikeB | last post by:
Hello All, want to be able to pull images from the database and load them into a bitmap through a stream which I have working. I then want to take the bitmap and load it into a Image control...
0
by: manjitsarma | last post by:
I need to display an image in 'Image Control' of aspx page.Now the image is displayed in the aspx page itself.But I need to display it in 'Image Control'.This is a map application and the image is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.