Ask a Question related to ASP.NET General, Design and Development.
-
Satish Appasani #1
Maintain an uploaded Image in a Session
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 tab, I am loosing the file in the file
control. So, I am putting the file in a Session:
Session("PhotoFile") = filePhoto.PostedFile
When the user comes back to the tab with the File upload, an Image control
displays the Image from the session. To make this work, I have built another
aspx page with only code to retrieve the Image from the session. To the
Image control in the parent form, I 'm setting it's ImageURL property to
"Image.aspx" (The file which contains code to retrieve the Image from the
session)
Dim lpostedFile As HttpPostedFile = Session("PhotoFile")
Dim lfilePhoto As HttpPostedFile = Session("PhotoFile")
Dim lintFileSize As Integer = lfilePhoto.ContentLength
Dim lsFileName As String = Right(lfilePhoto.FileName, _
Len(lfilePhoto.FileName) - lfilePhoto.FileName.LastIndexOf("\") - 1)
Dim lsContentType As String = lfilePhoto.ContentType
Dim lstreamImage As IO.Stream = lfilePhoto.InputStream
Dim lbytePhoto(lintFileSize) As Byte
lstreamImage.Read(lbytePhoto, 0, lintFileSize)
Response.ContentType = lsContentType
Response.BinaryWrite(lbytePhoto).
This works fine when I come back to the Image tab for the first time. The
Image control displays the uploaded Image. But If I refresh the page or go
to another tab and return back, the Image is not displayed. When I debug,
all the varibales display correct values which means there is no problem
with the Session.
I have worked around this by Saving the uploaded file to the server and
setting the Image's ImageURL property to the file. This works but I don't
want to do this as the site will be used globally and over the time this
will affect other resources like disk space. Can somebody please help me
with this.
Also, I've a report where I retrieve the Images from the database and
display them on the web page. As this report is too customized, I've to
build the page by dynamically generating HTML using the script. How can I
display each Image from the database on the page? Trying to save the Image
in the file system and then putting in to the HTML is going to be very very
expensive on the file system. Or generating the Image in a separate aspx
page and setting src of the Image to the aspx file will display the last
retrieved Image by Image.aspx for all the Images in the report. Please
provide me a solution for this too...
The last thing I can do is, as this site is an Intranet site and needs
authentication for the users, create a directory for the session in the
server and put all the Image files used by the user in to the directory.
When the session ends, delete the directory. But there should be a better
solution for this.
Thanks in advance.
--
Thank you.
Satish Appasani
#201, Wing - 1, Block - D
Cyber Gateway
Hyderabad - 500 081, India
Phone: +91(40)2311-1356 Ext-122
Mobile: +91(40)333-31032
E-mail: [email]satish@vertexcs.com[/email]
Satish Appasani Guest
-
How to maintain session b/w mxml files
Hi , I am a newbie for flex developement. i have created two files called signin.mxml and signout.mxml in signin.mxml i will collect the... -
Limiting uploaded image width in user-posted content?
I have created a blogging system where users can upload pics to their galleries then place them into their blogs by way of <img> tags. The problem... -
Resize uploaded image
I want to resize the images that the user may upload on our server. What I want is to resize the width and the height. How to do so ? -
HowTo Send Uploaded File with INPUT Type file to Sql Server Image Data Type ?
I have the following problem: I have the following form client side: <FORM.......> <FORM action="./WZUpload.asp" method="Post"... -
How to reduce an image size and still maintain high resolution clarity?
Can you tell me how to reduce an image size and still maintain high resolution clarity? I have a small logo in one layer of a multiple layers...



Reply With Quote

