Parsi Coders
سورس کد اپلود کردن فایل (asp.net) - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Web Development and Design (http://parsicoders.com/forumdisplay.php?fid=47)
+--- انجمن: ASP, ASP.NET (http://parsicoders.com/forumdisplay.php?fid=49)
+--- موضوع: سورس کد اپلود کردن فایل (asp.net) (/showthread.php?tid=2444)



سورس کد اپلود کردن فایل (asp.net) - Amin_Mansouri - 06-17-2012

کد:
Simple Upload in ASP.NET<%@ Page Language="VB" Debug="true" %>
<%@ import namespace="System.IO" %><script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
if page.isPostBack
Dim strFilePath As String = strFile.PostedFile.FileName
Dim i As Integer = InStr(1, StrReverse(strFilePath), "\")
Dim strFileName As String = Mid(strFilePath, (Len(strFilePath) - i) + 2)
strFile.PostedFile.SaveAs("c:\websites\articles\" & strFileName)
fileUploading.visible = false      
msg.text =  "File Uploaded ..."
  end if                    
end sub
</script>
<html>
<head>
</head>
<body>
<form id="fileUploading" runat="Server" enctype="multipart/form-data">
<b>Image :</b> <input id="strFile" type="file" runat="Server" />
<input type="submit" id="AddImage" value="Upload Image"  runat="server" />
</form>
<asp:label id="msg" runat="server"/></body>
</html>