الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف اعمل button ال upload

مغلق
بدأه emadmilan في 8 يناير 2007 · 2 رد · 896 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلا م عليكم

اخواني انا بدي اعمل button و textbox بحيث لما اضغط على ال button يطلعلي ال dialog الخاص بالبحث عن ملف بامتداد الصور وبعد ايجاد الصورة اضغط على ال submit ويقوم بأدخاله الى ال data base

يعني من الاخر بدي اعمل زر الابلود

هل من الممكن تحكولي كيف اعمل ال button وشو هو كود ال data base

مع العلم انو انا بستخدم ال vb.net 2003

post-81997-1168246913_thumb.jpg

#2

جرب هذا الرابط

/index.ph...p;hl=fileupload

وهنالك مواضيع كثيرة بالمنتدى تتكلم عن هذا الموضوع

#3

انسخ الكود التالي في صفحة HTML :

<INPUT id="myFile" style="WIDTH: 310px; HEIGHT: 22px" type="file" size="32" name="myFile"
	runat="server">

ثم الستخدم الكود التالي مع التعديلات المناسبة :

	

Private Sub Upload()

		Try 'Using a Try - catch prosedure to handle unhandled exceptions.
			If Not (myFile.PostedFile Is Nothing) Then
				Dim intFileNameLength As Integer
				Dim strFileNamePath As String
				Dim strFileNameOnly As String
				Dim Test As String

				'Be sure to add a folder called "Documents" 
				'in the same directory as your application.

				'The Server.MapPath("Documents\") is telling 
				'to upload the files to a folder called
				'Documents in the same path as the application.
				Dim FilePath As String = Server.MapPath("Documents\")

				'Logic to find the File Name (excluding the path)
				strFileNamePath = myFile.PostedFile.FileName
				intFileNameLength = InStr(1, StrReverse(strFileNamePath), "\")
				strFileNameOnly = Mid(strFileNamePath, _
						 (Len(strFileNamePath) - intFileNameLength) + 2)


				'Logic to find the extension. I have choosen 
				'to only upload pdf's doc's and xls's.
				'If you don't use any limitation, take it away.

				Test = Right(strFileNameOnly, _
					   strFileNameOnly.Length - _
					   strFileNameOnly.IndexOf(".") - 1)

				If Test = "pdf" Or Test = "doc" Or Test = "xls" Then
					'In my prosject I will limit the size 
					'on the file to 0,5Mbit.
					If CStr(myFile.PostedFile.ContentLength) < 500000 Then
						'Make the message labels visible
						lblFileContentType.Visible = True
						lblFileSize.Visible = True

						myFile.PostedFile.SaveAs(FilePath & (strFileNameOnly))
						' Yust a message to the client.
						lblMsg.Text = "The upload is finished."
						' A message showing the content type.
						lblFileContentType.Text = "The content is: " _
									   & myFile.PostedFile.ContentType

						'A message showing the file size.
						lblFileSize.Text = "The size of the file is: " _
						  & CStr(myFile.PostedFile.ContentLength) & " bytes"
					Else
						lblMsg.Text = "The file was to big."
						'A message to the client.
					End If
				Else
					lblMsg.Text = "This was not a pdf, " & _
					   "doc or xls file."  'A message to the client.
				End If
			Else
				lblMsg.Text = "You did't choose any document."
				'A message to the client.
			End If
		Catch ex As Exception
			lblMsg.Text = "An unhandled exeption occured." & _
						" Try again." 'A message to the client.
		End Try
	End Sub

تم تعديل هذه المشاركة بواسطة Scoool في 9 يناير 2007 في 13:23

هذا الموضوع مغلق.

مواضيع مشابهة