1. 程式人生 > >FileUpload上傳控制元件用法詳解--來自MSDN幫助文件

FileUpload上傳控制元件用法詳解--來自MSDN幫助文件

Visual Basic  “複製”影象 複製程式碼
<%@ Page Language="VB"
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>

<script runat="server"
>
    Sub
 UploadButton_Click(ByVal
 sender As
 Object, ByVal
 e As
 System.EventArgs)

        ' Save the uploaded file to an "Uploads" directory
' that already exists in the file system of the ' currently executing ASP.NET application. ' Creating an "Uploads" directory isolates uploaded ' files in a separate directory. This helps prevent ' users from overwriting existing application files by ' uploading files with names like "Web.config".
Dim saveDir As String = "/Uploads/" ' Get the physical file system path for the currently ' executing application. Dim appPath As String = Request.PhysicalApplicationPath ' Before attempting to save the file, verify ' that the FileUpload control contains a file.
If (FileUpload1.HasFile) Then Dim savePath As String = appPath + saveDir + _ Server.HtmlEncode(FileUpload1.FileName) ' Call the SaveAs method to save the ' uploaded file to the specified path. ' This example does not perform all ' the necessary error checking. ' If a file with the same name ' already exists in the specified path, ' the uploaded file overwrites it. FileUpload1.SaveAs(savePath) ' Notify the user that the file was uploaded successfully. UploadStatusLabel.Text = "Your file was uploaded successfully." Else ' Notify the user that a file was not uploaded. UploadStatusLabel.Text = "You did not specify a file to upload." End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server" > <title>FileUpload Class Example</title> </head> <body> <h3>FileUpload Class Example: Save To Application Directory</h3> <form id="form1" runat="server" > <div> <h4>Select a file to upload:</h4> <asp:FileUpload id="FileUpload1" runat="server" > </asp:FileUpload> <br/><br/> <asp:Button id="UploadButton" Text="Upload file" OnClick="UploadButton_Click" runat="server" > </asp:Button> <hr /> <asp:Label id="UploadStatusLabel" runat="server" > </asp:Label> </div> </form> </body> </html>

相關推薦

FileUpload控制元件用法--來自MSDN幫助

Visual Basic  複製程式碼 <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD

解決FileUpLoad控制元件,限制檔案大小

系統預設上傳檔案大小4096KB,如果我們要上傳超過此大小的檔案,會出現錯誤介面等…… 其實,只要我們對web.config檔案做一下配置,就可以輕鬆搞定你的“難題”! 在配置檔案中新增如下程式碼: <configuration>     <system.

MFC控制元件:listbox控制元件用法

ListBox的操作比較簡單 1新增資料 宣告控制元件變數的類別為Control,變數型別為CListBox,變數名為m_ListBox_Content. m_ListBox_Content.AddString(_T("123")); m_ListBox_Content.AddString(_T("漢字")

listbox控制元件用法

ListBox基本功能首先是列表項的新增,客戶端實現程式碼新增在listbox例項化程式碼中間,例如: <asp:ListItem Value="value" Selected=True>Text</asp:ListItem> 若在伺服器端實現,為避免每次載入時執行新增列表項,上述程式

linux cp命令參數及用法---linux 復制命令cp

linux file linux cp命令參數及用法詳解---linux 復制文件命令cp [root@Linux ~]# cp [-adfilprsu] 來源檔(source) 目的檔(destination)[root@linux

Asp.net_檔案控制元件FileUpload用法初步

1.aspx <asp:FileUpload ID="fudTest" runat="server" /> <asp:Button I

C# ASP.NET控制元件fileupload的使用

程式碼實現了簡單的圖片上傳功能(改一下也可以上傳其他的),沒有做圖片大小和格式的判斷,主要是熟悉fileupload控制元件 介面程式碼: <%@ Page Language="C#" Aut

檔案控制元件Fileupload(實現檔案並寫入資料庫)

首先我們來說一下Fileupload這個檔案上傳控制元件的幾大敗筆: 1.上傳之後按F5重新整理,重複提交 2.提交以後按後退鍵Fileupload中的資訊還在 3.不支援多檔案上傳 4.上傳前不能檢測檔案大小 解決方法: 1.建立iframe在子頁面實現或者重定向語句(R

ASP.NET控制元件——FileUpload控制元件和File控制元件

FileUpload控制元件<?XML:NAMESPACE PREFIX = O /> FileUpload Control 應用程式中經常需要允許使用者把檔案上傳到web伺服器。儘管在ASP.NET 1.X也可以完成該功能,但在ASP.NET 2.0中使用Fil

asp.net ajax 和 asp.net 2.0中的fileupload合力打造無重新整理檔案控制元件

{20        bool fileOK =false;21        //獲取根檔案絕對路徑22string path = Server.MapPath("~/UpLoad/");23        //如上傳了檔案,就判斷檔案格式24        FileUpload FU = FileUplo

js判斷控制元件FileUpload是否選擇和檔案型別

function CheckWorkFile() { var obj = document.getElementById('FileUpload1'); if (obj.value == '') { alert('請選

自定義控制元件實現

FileReader 物件 存檔 方便以後拿來即用 可以整合 canvas圖片裁剪進行實現 <input type="file" value="提交" id="file"> <button id="btn">上傳圖片並預覽</button>

Bootstrap之fileinput檔案控制元件

 前言~ 前段時間做專案用到了bootstrap裡中的檔案上傳控制元件,對此特定寫這篇文章,講述一下bootstrap的檔案上傳空間的使用方法。 我們進入正題吧!        首先bootstrap是基於jquery的,因此要匯入

百度編輯器Ueditor控制元件相關問題解決

1、問題原因: 由於百度編輯器相關jar包裡面的class檔案在某些特殊的情況下無法完全引入,或者映入過後無法讀取config.json的配置檔案導致上傳的相關配置不正確。 2、解決辦法: 修改ueditor.config.js的配置讀取的控制器層介面地址(注:該地址用於返回上

selenium藉助AutoIt識別(下載)

From: http://www.cnblogs.com/fnng/p/4188162.html AutoIt目前最新是v3版本,這是一個使用類似BASIC指令碼語言的免費軟體,它設計用於Windows GUI(圖形使用者介面)中進行自動化操作。它利用模擬鍵盤按鍵,滑鼠移動和視窗/控制元件的組合來

Android關於FTP檔案和下載功能

Android關於FTP檔案上傳和下載功能詳解  更新時間:2017年09月21日 11:41:14   作者:一諾的祕密花園    我要評論 這篇文章主要為大家詳細介紹了Android關於FTP檔案上傳和下載功能,具有一定的參考價值,感興趣

Python + Selenium + AutoIt 模擬鍵盤實現另存為、、下載操作

前言 在web頁面中,可以使用selenium的定位方式來識別元素,從而來實現頁面中的自動化,但對於頁面中彈出的檔案選擇框,selenium就實現不了了,所以就需引用AutoIt工具來實現。 AutoIt介紹 AutoIt簡單介紹下,AutoIt 目前最新是v3版本,這是一個使用類似BASIC指令碼語言的免費

檔案~Uploadify控制元件

namespace EntityFrameworks.Application.Core.FileUpload { /// <summary> /// 影象上傳功能的實現 /// </summary> public class UploadImp

扒一扒使用boostrap-fileinput外掛遇到的坑,Bootstrap-fileinput外掛的使用

轉自 https://blog.csdn.net/zlb_lover/article/details/76548772 由於公司專案的需求,需要實現動植物名錄的新增,包括姓名等資訊和圖片等,需要使用bootstrap-fileinput的上傳外掛,在提交新增介面

Android開發之基本控制元件四種佈局方式

Android中的控制元件的使用方式和iOS中控制元件的使用方式基本相同,都是事件驅動。給控制元件新增事件也有介面回撥和委託代理的方式。今天這篇部落格就總結一下Android中常用的基本控制元件以及佈局方式。說到佈局方式Android和iOS還是區別挺大的,在iOS中有F