473,289 Members | 1,961 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,289 software developers and data experts.

Problem viewing uploaded images using ASP.NET

Hello,
I use this script to upload image files to a folder on a IIS6 server:
******************* START UPLOAD.ASPX FILE **********************
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
Sub SubmitButton_Click(Source As Object, e As EventArgs)
If Not (oFile.PostedFile Is Nothing) Then
Try
'Declare variables
Dim strFileName As String
Dim strFilePath As String
Dim strFolder As String
Dim strPicType As String
Dim strPicSize As String
'Set Upload Folder
strFolder = "D:\Inetpub\wwwroot\upload\"
'Get the name of the file that is posted
strFileName = oFile.PostedFile.FileName
strFileName = Path.GetFileName(strFileName)
strFilePath = strFolder & strFileName
'Validate that it is an image file
strPicType = oFile.PostedFile.ContentType
strPicSize = oFile.PostedFile.ContentLength
If (strPicType="image/jpeg" or strPicType="image/gif" or
strPicType="image/pjpeg" or strPicType="image/bmp") then
'Save file
oFile.PostedFile.SaveAs(strFil*ePath)
Span.InnerHtml = "De afbeelding werd succesvol
bewaard!<BR><IMG SRC='http://www.a-random-website.co*m/upload/" &
strFileName & "'><BR>" & strPicSize & "."
Else
Span.InnerHtml = "De afbeelding is niet van het formaat
GIF, JPG,
JPEG of BMP!"
End If
Catch ex As Exception
Span.InnerHtml = "Er is een fout opgetreden bij het
bewaren van de afbeelding. Probeer het eens opnieuw."
End Try
End If
End Sub
</script>
<html>
<head>
<title>Title</title>
</head>
<body>
<FONT FACE="Trebuchet MS, Arial, Helvetica, Verdana" SIZE="2"
COLOR="#4E69B0">
<form runat="server" enctype="multipart/form-data">
Selecteer de afbeelding die je wenst toe te voegen:<br />
<input type="file" id="oFile" runat="Server"><br/>
<input type="submit" id="Submit" runat="Server"
value="Upload File" OnServerClick="SubmitButton_Cl*ick">
<p>
<span id="Span" runat="Server" />
</form>
</FONT>
</body>
</html>
******************* END UPLOAD.ASPX FILE **********************
The folder where the images are uploaded to is called upload and
located in the wwwroot folder (D:\Inetpub\wwwroot\upload\). I assigned
write permission to it to be able to save file via script.
This script is working and the file is uploaded correctly. But when I
then want to view the uploaded image using the webbrowser, I am
prompted to logon using windows security.
When I upload an image to the same upload folder
(D:\Inetpub\wwwroot\upload\) using FTP then I can see the image without

being prompted to logon. It seems that it has nothing to do with the
security on the folder, but with the security set on the saved file
using the ASP.NET script.
Who can help me out? What is wrong, do I use a wrong method or can I
set security on the saved file?
Already thanks for your help!

Nov 19 '05 #1
5 2702
Is there really nobody who can assist me on this? I can not find any
information on it issue.
In short: I can post images with FTP and the uploadform to the same
folder that has WRITE rights assigned. But when I want to VIEW the
images I can only see the images posted via FTP without being prompted
for a userid and password.

I think that it must have something to do with the ASP.NET account on
that folder. The problem with that is that I only can control the
permission via a webbased admin tool that the provider have made
available for me. The only options are WRITE and READ, without being
able to specify an account name. Or I need a confirmation from this so
I can instruct the provider to assign the correct rights to the folder
or I need a workaround that is still secure.

Thanks!

Nov 19 '05 #2
Hi IkBenHet,

Part of the reason you may not have received a reply is the way you asked
the question. For example, "I can post images with FTP and the uploadform" -
What exactly does this mean? There is no such thing (to us) as "the
uploadform." You know what you're referring to, but we do not. It helps to
be spcific about what your terms mean. Also, "I can control the permission
via a webbased admin tool" - Again, what is "the permission?" We have to
guess from the context.

IOW, in order to get an answer, it is important to make it as easy as
possible for people to understand exactly what you're asking, and what your
problem is. Of course, you don't always know what your problem is, but in
that case, pretend you're talking to a car mechanic, and you don't
understand cars. For example, one might describe a car problem to a mechanic
by saying "When I'm driving very fast, and I suddenly put my foot on the
brake and press very hard, I hear a screeching sound coming from the left
front side of the car. However, when I'm driving at a normal speed, I don't.
And when I hear the screeching sound, it only comes from the left front side
of the car." The mechanic can then make an educated guess, based upon the
very specific symptoms you've described, and his knowledge of cars, what the
problem may be. He might then be able to ask you some follow-up questions
about the symptoms to narrow down the problem.

So, on to my best guess as to what you mean, and what it might indicate.
Plainly, you are experiencing some sort of permission issue. Apparently,
something you describe as yourself ("I want to VIEW...") is having some
difficulty reading the images. I don't know whether your'e referring to an
ASP.Net application, or a browser. The answer depends upon what you are
referring to.

You say that it apparently has "something to do with the ASP.Net account on
that folder," but again, I can't assume that until I know specifically what
the problem is. If it is a problem with your app reading the files, that is
the case. On the other hand, if the client browser can't read the files,
it's the anonymous (probably, but I can't tell for sure - that depends on
the security settings on your web site with regards to anonymous access)
Internet user account that doesn't have permission to read the files in that
folder.

The answer to your question depends on the answer to my questions. Now,
again, I'm going to go out on a limb and guess that the "webbased admin tool
that the provider have made available for me" is a web-based web
administration tool that allows you to grant limited permissions for client
browsers to either read and/or write to folders inside your web. If that is
the case, and if it is the case that your ASP.Net app cannot read from that
folder, then the provider will have to set the permissions.

Again, I can give you a better answer if you can answer all of my
questions.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"IkBenHet" <ik********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Is there really nobody who can assist me on this? I can not find any
information on it issue.
In short: I can post images with FTP and the uploadform to the same
folder that has WRITE rights assigned. But when I want to VIEW the
images I can only see the images posted via FTP without being prompted
for a userid and password.

I think that it must have something to do with the ASP.NET account on
that folder. The problem with that is that I only can control the
permission via a webbased admin tool that the provider have made
available for me. The only options are WRITE and READ, without being
able to specify an account name. Or I need a confirmation from this so
I can instruct the provider to assign the correct rights to the folder
or I need a workaround that is still secure.

Thanks!

Nov 19 '05 #3
Hello Kevin,

When you see the script in the first thread. And I explain to you that
when I use that script to upload image files to a virtual folder that
has write permission assigned. When I do that using a webbrowser (so I
browse to the URL where the above ASP.NET script has been made
available) I am able to upload the image file and is saved in
correctly. No problem so far, the script it doing what it should do.

But, when I than try to open the uploaded image file using a
webbrowser, I am
prompted for a Windows logon screen in my webbrowser.

Trying to solve my problem I uploaded a test image using FTP to the
same folder as where the image file is located that I just uploaded
using the ASP.NET script. When I try to open that image file using a
webbrowser I am NOT prompted for a Windows logon box.

So, I think to conclude that the ASP.NET script has the right to save
the image files to the folder. (the file is saved in the folder) But I
think for some reason it is saving it with a different permissions
assigned as when I upload it using FTP.

What I tried to explain with the webbased administration tool from the
provider is that I can not see what actual permissions are assigned to
the (uploaded) files and the folder. I only have the option to select a
file or folder and select: "WRITE", "READ", "RESTORE DEFAULT
PERMISSION".

For me it seems not have to do with the ASP.NET account because than I
would been unable to save the file in the folder. I must be some
default permission that is missing when saving a file using the ASP.NET
script.

Is there a function available in ASP.NET so I can list this permission
assigned to the image files and folder or even change it?

Thanks.

Kevin Spencer schreef:
Hi IkBenHet,

Part of the reason you may not have received a reply is the way you asked
the question. For example, "I can post images with FTP and the uploadform" -
What exactly does this mean? There is no such thing (to us) as "the
uploadform." You know what you're referring to, but we do not. It helps to
be spcific about what your terms mean. Also, "I can control the permission
via a webbased admin tool" - Again, what is "the permission?" We have to
guess from the context.

IOW, in order to get an answer, it is important to make it as easy as
possible for people to understand exactly what you're asking, and what your
problem is. Of course, you don't always know what your problem is, but in
that case, pretend you're talking to a car mechanic, and you don't
understand cars. For example, one might describe a car problem to a mechanic
by saying "When I'm driving very fast, and I suddenly put my foot on the
brake and press very hard, I hear a screeching sound coming from the left
front side of the car. However, when I'm driving at a normal speed, I don't.
And when I hear the screeching sound, it only comes from the left front side
of the car." The mechanic can then make an educated guess, based upon the
very specific symptoms you've described, and his knowledge of cars, what the
problem may be. He might then be able to ask you some follow-up questions
about the symptoms to narrow down the problem.

So, on to my best guess as to what you mean, and what it might indicate.
Plainly, you are experiencing some sort of permission issue. Apparently,
something you describe as yourself ("I want to VIEW...") is having some
difficulty reading the images. I don't know whether your'e referring to an
ASP.Net application, or a browser. The answer depends upon what you are
referring to.

You say that it apparently has "something to do with the ASP.Net account on
that folder," but again, I can't assume that until I know specifically what
the problem is. If it is a problem with your app reading the files, that is
the case. On the other hand, if the client browser can't read the files,
it's the anonymous (probably, but I can't tell for sure - that depends on
the security settings on your web site with regards to anonymous access)
Internet user account that doesn't have permission to read the files in that
folder.

The answer to your question depends on the answer to my questions. Now,
again, I'm going to go out on a limb and guess that the "webbased admin tool
that the provider have made available for me" is a web-based web
administration tool that allows you to grant limited permissions for client
browsers to either read and/or write to folders inside your web. If that is
the case, and if it is the case that your ASP.Net app cannot read from that
folder, then the provider will have to set the permissions.

Again, I can give you a better answer if you can answer all of my
questions.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"IkBenHet" <ik********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Is there really nobody who can assist me on this? I can not find any
information on it issue.
In short: I can post images with FTP and the uploadform to the same
folder that has WRITE rights assigned. But when I want to VIEW the
images I can only see the images posted via FTP without being prompted
for a userid and password.

I think that it must have something to do with the ASP.NET account on
that folder. The problem with that is that I only can control the
permission via a webbased admin tool that the provider have made
available for me. The only options are WRITE and READ, without being
able to specify an account name. Or I need a confirmation from this so
I can instruct the provider to assign the correct rights to the folder
or I need a workaround that is still secure.

Thanks!


Nov 19 '05 #4
Using third party web hosting services can be limiting sometimes.

Are you uploading files directly into your virtual root directory or
are you uploading them into a folder set aside for uploaded files? Try
to use a separate folder for your uploads and ask your web hosting
service to set the permissions for the folder so that everyone has
read/write access.

Bill E.
Hollywood, FL

Nov 19 '05 #5
Hello Bill,

I think this will be the only solution. A better one would be I
somebody could explain me how to set permissions on a file using
ASP.NET. I know that SAFileUp does not have a problem with permission,
so that is a way to do it.

Can somebody explain me what permissions are really needed, because
giving everybody (or IUSER) full read and write rights, seems to be a
good idea to me.

Thanks

Nov 19 '05 #6

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

Similar topics

4
by: NohaKhalifa | last post by:
Dear All; I'm developing a web site and i need to make adminisration for this site it's a site for Real Estates . But I don't need the administration to be online .. I want them to fill data...
3
by: Pitcairnia | last post by:
The basic purpose of the site is for authenticated users to post event listings, which often include photographs. The user is faced with a page where they can insert all of the information about...
1
by: Gary | last post by:
Is it possible to have a "floating" area designated to show an enlarged image of a thumbnail? Right now I'm using a script to enlarge the image, where it's at, onmouseover, but when it enlarges,...
10
by: NH | last post by:
I have a girdview with paging enabled. How can I add a message in the footer to say "Viewing records 1-15 of 45" etc Thanks
2
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
7
by: Zeb | last post by:
Hi all I've developed a shopping cart in C# and to allow moderators to upload product images, news images and downloadable PDFs, the app creates a folder for each product. I start out with the...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
2
JimWu
by: JimWu | last post by:
I'd like to add designed by myself web control "TextBox" on my page. But something wrong to appear message " Control 'ctl13' of type 'TextBox must be placed inside a form tag with runat=server. "...
10
by: Robert Huff | last post by:
Can someone offer suggestions why, on the same server (Apache 2.2.8), this works <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en-US"> <head> <link rel=stylesheet...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.