//
you're reading...
ASP.NET, IT-Center, Web Based

ASP.NET upload file

ASP.NET design script / HTML Script :

<table>
 <tr>
 <td valign="top" style="height: 18px">Sample Format Customer</td><td style="width: 254px; height: 18px;">
 <a runat="server" id="insert_update" href="../upload/sample/sample_import_customer.xls"><font color="blue">Sample Import Customer.xls</font></a>

 </td>
 </tr>

 <tr>
 <td>Upload File</td><td style="width: 254px"><asp:FileUpload ID="fileUpEx" name="fileUpEx" runat="server" />
 <span style="color: #ff0000">*</span>
 </td>
 </tr>
 <tr>
 <td></td><td style="width: 254px"> <asp:button ID="btnSubmit" runat="server" Text="Upload" /> </td>
 </tr>
 </table>

ASP.NET VB Script in Button Action :

If fileUpEx.HasFile Then
Try
 Dim filepath As String = fileUpEx.PostedFile.FileName
 Dim m As Match = r.Match(filepath)
 Dim file_ext As String = System.IO.Path.GetExtension(filepath)
 Dim filename As String = Path.GetFileName(filepath)
 Dim thefile As String = filename
'save the file to the server
 fileUpEx.PostedFile.SaveAs(Server.MapPath("..\upload\datamart\") & thefile)
Catch ex As Exception
 liBodyLoadAction.Text = "alert('" + ex.Message().Replace("'", "\'").Replace(vbCrLf, "\n") + "');"
 End Try
Else
 liBodyLoadAction.Text = "alert('Please select file to upload!');"
 End If

About berbagisolusi

Berbagi merupakan sebuah bentuk simbol keikhlasan untuk membantu dan menolong, sedangkan solusi adalah cara menyelesaikan masalah. Setiap manusia pasti mengalami masalah, tetapi kita tidak perlu mengalami masalah yang sama jika orang lain pernah mengalami dan kita tahu hal tersebut.

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 9 other followers

December 2011
M T W T F S S
« Nov   Jan »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Web Statistic

Blog Stats

  • 149,580 hits
%d bloggers like this: