قمت بانشاء موقع ويعمل على الجهاز بشكل سليم جدا
ويوجد قائمة لادخال صور وتحديثها أيضا
حيث أقوم بوضع الصورة داخل فلدر على الموقع ومسار الصورة داخل داتا بيز
والموقع يعمل على الجهاز
حين تم وضعه على الأنترنت لم أستطيع ادخال صور جديدة أو عمل تحديث لها ؟
If TextFileupload.PostedFile.FileName <> "" Then
Dim conn As New SqlConnection
Dim sql As New SqlCommand
Dim hany As String
Dim myFile As HttpPostedFile = TextFileupload.PostedFile
Dim Filename As String = System.IO.Path.GetFileName(myFile.FileName)
Dim ConactType As String = myFile.ContentType
myFile.SaveAs(Server.MapPath("City/" & Filename))
hany = "Update city_list SET "
hany &= "image_city='" & ("admin\City/" & Filename) & "'"
hany &= " Where id='" & Me.DropDownList1.SelectedItem.Value & "'"
Dim conn1 As New SqlConnection(connectionstring)
Dim cmd As New SqlCommand(hany, conn1)
Try
conn1.Open()
Dim up As Integer
up = cmd.ExecuteNonQuery
Label1.Text = "تمت عمليه تحديث الصورة"
Catch ex As Exception
Label1.Text = "error update uaser"
Label1.Text &= Err.Description
Finally
If (Not conn Is Nothing) Then
conn1.Close()
End If
End Try
Else
Label1.Text = "خطأ فى ادخال الصورة"
End Ifكود ادخال الصورة هو
Dim myFile As HttpPostedFile = TextFileupload.PostedFile
Dim Filename As String = System.IO.Path.GetFileName(myFile.FileName)
Dim ConactType As String = myFile.ContentType
Dim hany As String = TextBox2.Text
sql = New SqlCommand("insert into city_list(city,info,image_city) values (@1,@2,@3)", conn)
sql.Parameters.Add("@1", TextBox1.Text)
sql.Parameters.Add("@2", TextBox2.Text)
myFile.SaveAs(Server.MapPath("City/" & Filename))
sql.Parameters.Add("@3", ("admin\City/" & Filename))
conn.Open()
sql.ExecuteNonQuery()
Label1.Text = "تمت الإضافة"
TextBox2.Text = ""ما هى المشكله
الكود يعمل على الجهاز بشكل سليم ويوقم بارسال الصورة فى المكان المحدد مع حفظ المسار داخل الداتا بيز
لكن بعد رفع الموقع على السيرفر لا يعمل
ويرسل الخطأ التالي
هذا الخطأ
Server Error in '/' Application.
--------------------------------------------------------------------------------
Access to the path 'C:\Inetpub\vhosts\malaysia-daleel.com\httpdocs\admin\City\MA5.jpg' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\malaysia-daleel.com\httpdocs\admin\City\MA5.jpg' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
