السلام عليكم..المشكلة باختصار هي انه الصور لا تظهر لي في الصفحة و قيل لي انه بسبب صلاحيات ملفات الـ
NTFS
فهل يوجد من يعرف حل لهذه المشكلة
و هذه هي المشكلة باللغة الانجليزية
My problem is that when I include an image to my website using visual studio asp
.net 2008,I put a hyperLink to view the image but I have this error:
Server Error in '/WebSite6' Application.
HTTP Error 403 - Forbidden.
Also,I have used uploadfile control which works perfectly, and I've used a DataList
and I put image control in each template so I can view all the images that I have
uploaded into my website, everything goes will but instead of the image,I have an
empty image with a red X in it.
I searched alot for solution and am disappointed,so if you can help me I will be
very greatfull to you
I tried to install IIS, I almost did everything..please help me
and this is the code in case you need to take a look:
================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#form1
{
height: 233px;
}
</style>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
<b>Select file: </b>
<asp:FileUpload id="UploadFile" Width="400px" Runat="Server"/>
<asp:Button ID="Button1" Text="Upload" OnClick="Upload_Picture_File"
Runat="Server"/><br/>
<br/>
<asp:Label id="Message" ForeColor="#FF0000" EnableViewState="False" Runat="Server"/>
<br />
<br />
<br />
<asp:DataList id="PictureFiles" Runat="Server"
RepeatColumns="4"
RepeatDirection="Horizontal"
CellPadding="3"
GridLines="Both"
OnItemCommand="Delete_File">
<ItemTemplate>
<asp:Image ID="Image1" ImageUrl='<%# ".\\images\" & Container.DataItem %>'
Runat="Server"
Width="45" ImageAlign="Left"/>
<asp:Label ID="Label1" Text='<%# Container.DataItem %>' Runat="Server"/><br/>
<asp:Button ID="Button2" Text="Delete" Runat="Server"
Font-Size="7pt"
CommandName='<%# Container.DataItem %>'/>
</ItemTemplate>
</asp:DataList>
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
=============
This is the VB code:
=============
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Upload_Picture_File(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Not UploadFile.HasFile Then
'-- Missing file selection
Message.Text = "Please choose a file to upload"
'Else
' If InStr(UCase(UploadFile.FileName), ".JPG") = 0 Then
' '-- Selection of non-JPG file
' Message.Text = "You can upload only JPG files"
' Else
' If UploadFile.PostedFile.ContentLength > 100000 Then
' '-- File too large
' Message.Text = "Uploaded file size must be less than 100
KB"
Else
'-- File upload
UploadFile.SaveAs(Server.MapPath(".\\images\" & UploadFile.FileName))
Message.Text = "<b>File Uploaded</b><br/>"
Message.Text &= "File Name: " & UploadFile.FileName & "<br/>"
Message.Text &= "File Size: " & UploadFile.PostedFile.ContentLength & "
bytes<br/>"
Bind_Picture_Files()
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Not Page.IsPostBack Then
Bind_Picture_Files()
End If
End Sub
Sub Bind_Picture_Files()
Dim FileArray() As String = Directory.GetFiles(Server.MapPath(".\\images\"),
"*")
Dim i As Integer
For i = 0 To UBound(FileArray)
FileArray(i) = Replace(FileArray(i), Server.MapPath(".\\images\"), "")
Next
PictureFiles.DataSource = FileArray
PictureFiles.DataBind()
End Sub
Sub Delete_File(ByVal Src As Object, ByVal Args As DataListCommandEventArgs)
File.Delete(Server.MapPath(".\\images\") & Args.CommandName)
Bind_Picture_Files()
End Sub
End Class