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

عمل Upload لملفات كبيرة؟

مغلق
بدأه جويعد في 15 يوليو 2007 · 3 رد · 1,107 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لدي مشكلة وهي إني كلما أعمل Upload لملف صوتي كبير فإنه يرفع الملف، ولكن عند عمل Upload لملف صوتي حجمه صغير فإنه يتم الرفع بنجاح.

كيف أرفع الملفات ذوات الأحجام الكبيرة؟ علماً إني استخدم هذا الكود. ودمتم سالمين

<script runat="server">

	Protected Sub btnFileUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs)
		If myFileUpload.HasFile Then
			myFileUpload.SaveAs(Server.MapPath("sounds/" & myFileUpload.FileName))
		End If
	End Sub

</script>
		<asp:FileUpload ID="myFileUpload" runat="server" />
		<asp:Button ID="btnFileUpload" runat="server"
			Text="Upload File"
			OnClick="btnFileUpload_Click"
		/>
#2

يجب عليك رفع الحد الأعلى لحجم الملفات من داخل ملف web.config

داخل قسم <system.web> إذهب إلى httpRuntime وغير قيمة maxRequestLength (القيمة بالكيلوبايت) لتصبح مثلاً:

<httpRuntime maxRequestLength="15000" />

http://msdn2.microsoft.com/en-us/library/e...641(VS.80).aspx

#3

Upload larger files

By default, ASP.NET permits only files that are 4,096 kilobytes (KB) (or 4 megabytes [MB]) or less to be uploaded to the Web server. To upload larger files, you must change the maxRequestLength parameter of the <httpRuntime> section in the Web.config file.

Note When the maxRequestLength attribute is set in the Machine.config file and then a request is posted (for example, a file upload) that exceeds the value of maxRequestLength, a custom error page cannot be displayed. Instead, Microsoft Internet Explorer will display a "Cannot find server or DNS" error message.

If you want to change this setting for all of the computer and not just this ASP.NET application, you must modify the Machine.config file.

By default, the <httpRuntime> element is set to the following parameters in the Machine.config file:


executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>
<httpRuntime

The Machine.config file is located in the \System Root\Microsoft.NET\Framework\Version Number\Config folder.

هذا الكلام يعني أن الحد الأعلى لحجم الملف حوالي 4 ميجا ، إذا أردت أن تحمل الملف (أكبر من 4 ميجا) عليك

أن تعدل ملف WEB.CONFIG ومن ثم تضيف الكود السابق مع تعديل قيمة MAXREQUSETLENGTH حسب الحجم الذي

تريده ، هذا الكلام على مستوى التطبيق ، أما إذا اردت على مستوى الجهاز فعدل على الملف MACHINE.CONFIG مع العلم أن

هذه العملية قد يكون فيها بعضض الخطورة لأنك تتعامل مع هذا الملف على مستوى الجهاز ، قد يؤدي خطأ معين إلى ضرر على

مستوى ASP.NET + IIS

وشكرا

#4

أشكركما كثيرا .. الحمد الله لقد تم التغلب على المشكلة

جزاكما الله كل خير

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

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