Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Как загрузить с пользовательского PC Multimedia File ?
|
|||
|---|---|---|---|
|
#18+
В IIS для сайта установлены multimedia MIME, .. extention "mpg", type "video/mpeg". На странице имеются HTML Input File Control (accept="video/*") и Submit Button. После выбора mpg файла видим в Input File Control его путь и имя. При нажатии на кнопку Submit Button вылетаем: ----------------------------------------------- The page cannot be displayed The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings. Please try the following: Click the Refresh button, or try again later. If you typed the page address in the Address bar, make sure that it is spelled correctly. To check your connection settings, click the Tools menu, and then click Internet Options. On the Connections tab, click Settings. The settings should match those provided by your local area network (LAN) administrator or Internet service provider (ISP). If your Network Administrator has enabled it, Microsoft Windows can examine your network and automatically discover network connection settings. If you would like Windows to try and discover them, click Detect Network Settings Some sites require 128-bit connection security. Click the Help menu and then click About Internet Explorer to determine what strength security you have installed. If you are trying to reach a secure site, make sure your Security settings can support it. Click the Tools menu, and then click Internet Options. On the Advanced tab, scroll to the Security section and check settings for SSL 2.0, SSL 3.0, TLS 1.0, PCT 1.0. Click the Back button to try another link. Cannot find server or DNS Error Internet Explorer ----------------------------------------------- Причем вылет происходит до входа в submit_click, проверено в debugger. Там же есть Cancel Button, нажатие на нее дает тот же результат. Что и на каком этапе может вызвать такой эффект ? InputFile для картинок при выборе картинок на той же странице ведет себя нормально. Кстати, существует ли возможность после обращения к серверу восстановить в InputFile строку пути ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 13.01.2004, 23:38 |
|
||
|
Как загрузить с пользовательского PC Multimedia File ?
|
|||
|---|---|---|---|
|
#18+
не сталкивался с такой необходимостью, но вот вроде бы статья в тему - ссылки к сожалению нет. This article presents a step-by-step procedure to upload a file to a web server using Visual C#. In this article you will create the ASP.NET file called Webform1.aspx (and its related codebehind file, webform1.aspx.cs) to upload files to a directory called 'data'. Create an ASP.NET Application ----------------------------- Using Visual Studio .NET will create a new application to upload files to the web server. 1. Open Visual Studio .NET. 2. Select File | New | Open Project menu command. 3. The New Project dialog box appears. Under Project Types, select Visual C# Projects. Under Templates, select ASP.NET Web Application. In the Location textbox, enter the URL to create the project. This example will use http://localhost/CSharpUpload, thereby creating the default project name of CSharpUpload. 4. The WebForm1.aspx file loads in the Designer View of Visual Studio .NET. Create the Data Directory ------------------------- Once the application has been created, you will create the data directory that will accept uploaded files. Once this directory has been created, you will also need to set write permissions for the ASPNET worker account. 1. In the Solution Explorer, right click the project name CSharpUpload, and select the Add | New Folder menu command. 2. A new folder called NewFolder1 is created. To change the folder name, right click NewFolder1, and select the Rename menu command. Change the folder name to data. 3. Open Windows Explorer. 4. Using Windows Explorer, navigate to the file system folder you just created called data, by default, this location is C:\Inetpub\wwwroot\ CSharpUpload\data. 5. To change the security settings, and allow write permissions to the data directory, right click data and select Properties. The data Properties dialog box appears. 6. Click the tab labeled Security. Click Add, the Select Users or Groups dialog box appears. Select the account named ASPNET, and click Add. Click OK. The Select Users or Groups dialog box closes. 7. With the aspnet_wp account (<computername>\ASPNET) account highlighted, Allow the following permissions Read and Execute, List Folder Contents, Read, and Write. Uncheck all other Allow and Deny checkboxes. 8. Click OK. The data Properties dialog box closes. The data directory permissions have now been modified to accept user uploaded files. Modify the Webform1.ASPX ASP.NET Page ------------------------------------- In Visual Studio .NET the Webform1.aspx page should already be loaded in the designer window. In the next few steps you will modify the HTML of webform1.aspx to allow users to upload files. 1. Switch back to the open instance of Visual Studio .NET. Webform1.aspx should be open in the Designer Window. 2. To view the HTML source of Webform1.aspx, right click Webform1.aspx, in the Designer Window, and select the View HTML Source menu command. 3. Navigate and locate the following HTML code containing the FORM tag. <form id="Form1" method="post" runat="server"> 4. Add the enctype="multipart/form-data" name-value attribute to the FORM tag to read <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> 5. After the opening FORM tag, add the following code: <INPUT type=file id=File1 name=File1 runat="server" /> <br> <input type="submit" id="Submit1" value="Upload" runat="server" /> 6. Once this has been completed, the entire HTML FORM will read: <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> <INPUT type=file id=File1 name=File1 runat="server" /> <br> <input type="submit" id="Submit1" value="Upload" runat="server" /> </form> Add Upload Code to Webform1.ASPX.CS Codebehind File --------------------------------------------------- Once the .aspx HTML has been changes have been completed, the Webform1.aspx.cs codebehind file will need to be modified to accept the uploaded data. 1. Select the View | Design menu command. The Webform1.aspx file changes from HTML mode to Design mode. 2. Double click on the Submit button labeled Upload. Visual Studio opens the file WebForm1.aspx.cs, and automatically generates the following method code: private void Submit1_ServerClick(object sender, System.EventArgs e) { } 3. Verify the following code exists at the class level of the WebForm1.cs protected System.Web.UI.HtmlControls.HtmlInputFile File1; protected System.Web.UI.HtmlControls.HtmlInputButton Submit1; If this code is not located in the file, enter it after the lines public class WebForm1 : System.Web.UI.Page { 4. Scroll to the line private void Submit1_ServerClick(object sender, System.EventArgs e) { 5. Press enter to add a blank line, and type the following code. if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) ) { string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName); string SaveLocation = Server.MapPath("Data") + "\\" + fn; try { File1.PostedFile.SaveAs(SaveLocation); Response.Write("The file has been uploaded."); } catch ( Exception ex ) { Response.Write("Error: " + ex.Message); } } else { Response.Write("Please enter a file to upload."); } The code first checks to verify a file has been uploaded. If no file was selected, the message Please enter a file to upload. is printed to the screen. If a valid file is uploaded, its file name is extracted using the System.IO namespace, and assembles its destination SaveAs path. Once the final destination is known, the file is saved, using the File1.PostedFile.SaveAs() method. Any exception is trapped and the exception message is sent to the screen. or your reference, the entire Submit1 subroutine should match the following code. private void Submit1_ServerClick(object sender, System.EventArgs e) { if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) ) { string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName); string SaveLocation = Server.MapPath("Data") + "\\" + fn; try { File1.PostedFile.SaveAs(SaveLocation); Response.Write("The file has been uploaded."); } catch ( Exception ex ) { Response.Write("Error: " + ex.Message); } } else { Response.Write("Please enter a file to upload."); } } Test the Application -------------------- The following steps will build your Visual Studio .NET solution and test the application. 1. In Visual Studio .NET, to build the application, select the Build | Build Solution menu command. 2. In the Solution Explorer, right click the Webform1.aspx file, and select the View In Browser menu command. 3. Once Webform1.aspx loads in the Browser, click the Browse button located on the webpage. The Choose File dialog box opens. 4. Browse to a file under 4MB in size and click Open. The Choose File dialog box closes. To upload the file, click the button labeled Upload. 5. The file uploads to the web server and the message The file has been uploaded. is displayed. 6. Switch to the open instance of Windows Explorer, and navigate to the directory named data. 7. Verify the file has been uploaded to the data directory. Upload Larger Files ------------------- By default, ASP.NET only allows files up to 4096KBytes (4MB) in size to be uploaded to the web server. To upload larger files, you will need to change the maxRequestLength parameter of the <httpRuntime> section found in the web.config file. If you wish to change this setting across the entire machine, and not just this ASP.NET application, you will need to modify the machine.config file. By default the <httpRuntime> is set to the following parameters in machine.config file. <httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" /> The machine.config file can be found in the C:\WINNT\Microsoft.NET\Framework\v1.0.3705\CONFIG directory. Complete Code Listing --------------------- For your reference, the complete code listing for WebForm1.aspx and WebForm1.aspx.cs can be found below. WebForm1.aspx <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="CSharpUpload.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name=vs_defaultClientScript content="JavaScript"> <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> <INPUT type=file id=File1 name=File1 runat="server" > <br> <input type="submit" id="Submit1" value="Upload" runat="server" NAME="Submit1"> </form> </body> </HTML> WebForm1.aspx.cs using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace CSharpUpload { /// <summary> /// Summary description for WebForm1. /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlInputFile File1; protected System.Web.UI.HtmlControls.HtmlInputButton Submit1; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Submit1.ServerClick += new System.EventHandler(this.Submit1_ServerClick); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Submit1_ServerClick(object sender, System.EventArgs e) { if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) ) { string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName); string SaveLocation = Server.MapPath("Data") + "\\" + fn; try { File1.PostedFile.SaveAs(SaveLocation); Response.Write("The file has been uploaded."); } catch ( Exception ex ) { Response.Write("Error: " + ex.Message); } } else { Response.Write("Please enter a file to upload."); } } } } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.01.2004, 15:48 |
|
||
|
Как загрузить с пользовательского PC Multimedia File ?
|
|||
|---|---|---|---|
|
#18+
Спасибо за статью. Все условия вроде бы выполнены. Кнопки, правда, aspx, а не обычные, но это не мешает общаться с картинками (см.выше). В web/config присутствует <configuration> <system.web> <!-- 28M - Max file size on request --> <httpRuntime maxRequestLength="29360728" /> ..... (Кстати, при попытке установить maxRequestLength в 2 раза больше компиляция уже не проходит). Грешу я либо на mime, либо на величину файла (но она не достигает установленной maxRequestLength !). Может, еще какие-то установки мешают ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.01.2004, 21:09 |
|
||
|
Как загрузить с пользовательского PC Multimedia File ?
|
|||
|---|---|---|---|
|
#18+
Через 5 мин: все в порядке ! Еще раз на свежую голову посмотрела web.config, нашла там комментарий, что max request len 28M, поставила их в кач.своего max, файлы стали записываться. Почему при компиляции пропускается огромное число, и почему потом падаем, хотя его далеко не достигаем - вопрос к MS... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 14.01.2004, 21:27 |
|
||
|
|

start [/forum/topic.php?fid=18&tid=1396051]: |
0ms |
get settings: |
11ms |
get forum list: |
20ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
32ms |
get topic data: |
13ms |
get forum data: |
4ms |
get page messages: |
49ms |
get tp. blocked users: |
2ms |
| others: | 262ms |
| total: | 401ms |

| 0 / 0 |
