Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
coding asp untuk upload form
#1
Computer_16 
askum all.,.,.

nie W nemu dari tmen ane,,,,

kali j berguna bagi agan2 semua Bigsmile

cekidot !!!

Bagi seorang web programmer berbasis ASP seringkali menemui kendala dalam membuat aplikasi web
lengkap dengan halaman upload. Bagaimana tidak, untuk dapat membuat sebuah halaman upload saja,
seringkali seorang programmer harus menginstall/menambahkan komponen (ActiveX)
baru untuk menangani hal tersebut. Belum lagi komponen yang diinstal tersebut harus ditebus dengan
sejumlah duit alias tidak gratis.

Dalam artikel ini, saya akan membuat sebuah halaman upload tanpa
menggunakan/menginstall komponen (ActiveX) baru. Melainkan menggunakan beberapa
file yang di sertakan (include) bersama dengan file upload.
Untuk keperluan itu, terlebih dahulu persiaplan item-item berikut:
o Download file upload.inc, utils.inc
Setelah Anda memiliki ketiga file ini, extractlah difolder tempat semua file upload akan disimpan.
o Pastikan Web Server Anda telah aktif. Untuk web server bisa menggunakan PWS ataupun IIS.

Jika semua persiapan telah siap, maka langkah selanjutnya adalah membuat file form-upload.htm
dan upload-file.asp. Source codenya seperti berikut :

form-upload.htm


Quote:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width=508 align="center">
<form method=post ENCTYPE="multipart/form-data" action="file-upload.asp">
<tr bgcolor=silver>
<td colspan="2" align="right"><input type="submit" value="Upload the files >>"></TD>
</tr>
<tr>
<td colspan=2>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td width="9%">
File 1 :<br>
File 2 :
</td>
<td width="91%">
<input type="file" name="File1"><br>
<input type="file" name="File2">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>Comments</td>
<td><input size="60" name="Comments" value=""></td>
</tr>
<tr>
<td>Description</td>
<td><textarea cols="60" rows="8" name="Description"></textarea></td>
</tr>
</form>
</table>
</body>
</html>

upload-file.asp

Quote:<!--#include file="inc/upload.inc"-->
<!--#include file="inc/utils.inc"-->
<!--#include file="inc/format.inc"-->

<%
Option Explicit

Dim ResultHTML, DestinationPath, Upload, Field

Server.ScriptTimeout = 200

DestinationPath = Server.MapPath(".")'Folder to store uploaded files
LogFolder = Server.MapPath(".") 'Folder to store log file with info about upload request.

'Set upload limit to 1MB
UploadSizeLimit = 1000000

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then 'Request method must be "POST" For get the fields
'Gets uploaded fields
Set Upload = GetUpload()

ResultHTML = ""
If Err = 0 Then 'Upload was OK
'Write statistics about upload. Optional.
For Each Field In Upload.Items
If isarray(Field) Then
else
'ResultHTML = ResultHTML & "<br>Field : <b>" & LogF(Field.Name) & "</b>, Length : <b>" & LogFn(Field.Length) & "</b>, Content-Type : <b>" & LogF(Field.ContentType) & "</b>, SourceFileName : <b>" & LogF(Field.FileName) & "</b>"
ResultHTML = ResultHTML & "<br>Field : <b>"
ResultHTML = ResultHTML & LogF(Field.Name) & "</b>, Length : <b>"
ResultHTML = ResultHTML & LogFn(Field.Length)
ResultHTML = ResultHTML & "</b>, Content-Type : <b>"
ResultHTML = ResultHTML & LogF(Field.ContentType)
ResultHTML = ResultHTML & "</b>, SourceFileName : <b>"
ResultHTMl = ResultHTML & LogF(Field.FileName) & "</b>"

end if
Next

ResultHTML = ResultHTML & "<BR>" & SaveUpload(Upload, DestinationPath, LogFolder)

Else 'Error In upload. Write the error
ResultHTML = ResultHTML & "<br>Error : " & Err.Description
End If

Response.Write ResultHTML
On Error GoTo 0
Upload = Empty 'Clear the variable
End If 'Request method must be "POST"

%>


Catatan:
• File upload.inc berisi pernyataan fungsi dari GetUpload.
• File utils.inc berisi pernyataan fungsi SaveUpload.

Demikian artikel saya ini. Semoga dapat bermanfaat bagi teman-teman sekalian

waskum all.,.,.Bigsmile
[Image: YRtWp.1.gif]
Reply


Messages In This Thread
coding asp untuk upload form - by Wayc0de - 10-27-2010, 10:42 PM
RE: coding asp untuk upload form - by domblonk - 10-28-2010, 12:34 AM
RE: coding asp untuk upload form - by arDhi^_ - 10-28-2010, 03:20 AM
RE: coding asp untuk upload form - by Wayc0de - 10-29-2010, 01:24 AM
RE: coding asp untuk upload form - by N4is3N - 10-28-2010, 12:02 PM
RE: coding asp untuk upload form - by brotherceez - 10-28-2010, 12:29 PM
RE: coding asp untuk upload form - by arDhi^_ - 10-29-2010, 01:36 AM
RE: coding asp untuk upload form - by init-6 - 06-14-2011, 07:01 AM
RE: coding asp untuk upload form - by cmd.exe - 06-14-2011, 10:04 AM
RE: coding asp untuk upload form - by Gelby - 06-14-2011, 11:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SHARE] Tempat Upload Tool , Jalankan Script dll vba 14 376 08-10-2014, 05:20 AM
Last Post: positive
  [Ask] Masuk gan, php upload Image otomatis redirect roisbwi 5 107 08-10-2014, 05:15 AM
Last Post: positive
  Ndak bisa tampilin file yg di upload !! Big_Dark 5 102 08-10-2014, 05:11 AM
Last Post: positive
  Script PHP Upload File From URL CopSLacS 6 191 08-10-2014, 05:08 AM
Last Post: positive
  [SHARE] Aplikasi Perpustakaan (DIGILIB) untuk sekolah herubrondong 12 247 10-24-2013, 06:30 PM
Last Post: herubrondong
  [Share] Script PHP Web Proxy Untuk Web Hosting CopSLacS 9 197 09-24-2013, 10:36 AM
Last Post: CopSLacS
  [ASK] PHP untuk VOTING atau POLING ! Big_Dark 3 69 06-21-2013, 09:20 PM
Last Post: Big_Dark
Smile-pink_16 upload file PHP Virgin 14 343 03-29-2013, 02:02 PM
Last Post: Dika_xb
  [ask] send mail untuk Web (localhost) christsoon 9 122 09-18-2012, 07:36 AM
Last Post: compLann
Computer_16 [HELP] membuat form php mail() untuk request subdomain zhez_syntax 1 60 08-03-2012, 11:35 AM
Last Post: compLann

Forum Jump:


Users browsing this thread: 1 Guest(s)