Problem with uploading Image files.

I

IkBenHet

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!
 
I

IkBenHet

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top