Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Problem with uploading Image files.

Reply
Thread Tools

Problem with uploading Image files.

 
 
IkBenHet
Guest
Posts: n/a
 
      05-26-2005
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(strFilePath)
Span.InnerHtml = "De afbeelding werd succesvol
bewaard!<BR><IMG SRC='http://www.a-random-website.com/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_Click">
<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!

 
Reply With Quote
 
 
 
 
IkBenHet
Guest
Posts: n/a
 
      05-28-2005
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!

IkBenHet schreef:
> 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(strFilePath)
> Span.InnerHtml = "De afbeelding werd succesvol
> bewaard!<BR><IMG SRC='http://www.a-random-website.com/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_Click">
> <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!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ftp uploading vs. control panel uploading Dung Ping HTML 10 01-16-2006 10:43 AM
Problems uploading image to database Luis Esteban Valencia ASP .Net 0 10-20-2004 04:31 PM
QUESTION: Uploading of IOS image to Cisco 2504 using the console port ONLY Voitec Cisco 5 09-12-2004 02:25 PM
Image uploading Tom ASP .Net 2 12-20-2003 09:21 AM
Uploading an Image from a web page Paul Gorman ASP .Net 2 08-07-2003 02:44 PM



Advertisments