10/10/2018, 10:10

Upload file trong Localhost bằng ASP. Sao lại củ chuối thế. Cái lổi này mong được gúp

Tui có một cái trang web viet bằng ASP với Database Access nhưng khi upload file hình ảnh *.jpeg, *.gift. *.HTML, WMA,WMV... lên domain hosting thì được, nhưng khi chạy trong localhost thì nó báo lổi không Up được. Vậy muốn upload trong Localhost thì phải sửa lại cái gì mới được.! Mong các bác chỉ giáo cho.

Báo là file lib_upload.asp err line 17.
------------------------------------
Đây là nội dung file .
------------------------------------

<%
dim g_intUploadType
g_intUploadType=0
%>

<%
'uploadFile
sub uploadFile(strFileName, strFileLocation, blnUploadType)
'On Error Resume Next
dim objFileSystem
dim objUpload

if blnUploadType=0 then
set objFileSystem = CreateObject("Scripting.FileSystemObject")
if not(objFileSystem.FolderExists(strFileLocation)) then objFileSystem.CreateFolder(strFileLocation)

set objUpload= Server.CreateObject("Persits.Upload.1")
objUpload.SetMaxSize 5000000,true
objUpload.Save(strFileLocation)

strFileName=objUpload.Files("strFileName").Path
elseif blnUploadType=1 then

set objFileSystem = CreateObject("Scripting.FileSystemObject")
if not(objFileSystem.FolderExists(strFileLocation)) then objFileSystem.CreateFolder(strFileLocation)
Set objUpload= Server.CreateObject("SoftArtisans.FileUp")
objUpload.Path=strFileLocation

objUpload.Form("strFileName").Save

strFileName=objUpload.Form("strFileName").ServerNa me
end if

if (Err.number<>0) then
Response.Write Err.description
end if
end sub %>

<%'delFolder
sub delFolder(FolderPath)
dim objFileSystem, strFolderPath
set objFileSystem = CreateObject("Scripting.FileSystemObject")
if FolderPath <> "" then
strFolderPath=server.MapPath(FolderPath)
if objFileSystem.FolderExists(strFolderPath) then objFileSystem.DeleteFolder(strFolderPath)
end if
end sub
%>

<% 'del file
function delFile(strSource)
dim objFileSystem
dim fsFile
on error resume next
set objFileSystem=CreateObject("Scripting.FileSystemOb ject")
set fsFile=objFileSystem.GetFile(strSource)
fsFile.Delete true
end function

%>

<% sub uploadFile1(file1, file2, file3, file4, file5, file6, file7, file8, file9, file10, strFileLocation)
On Error Resume Next
dim fs
dim objUpload

if g_intUploadType=0 then
set fs = CreateObject("Scripting.FileSystemObject")
if not(fs.FolderExists(strFileLocation)) then fs.CreateFolder(strFileLocation)

set objUpload= Server.CreateObject("Persits.Upload.1")
objUpload.SetMaxSize 5000000,true
objUpload.Save(strFileLocation)

file1=objUpload.Files("file1").Path
file2=objUpload.Files("file2").Path
file3=objUpload.Files("file3").Path
file4=objUpload.Files("file4").Path
file5=objUpload.Files("file5").Path
file6=objUpload.Files("file6").Path
file7=objUpload.Files("file7").Path
file8=objUpload.Files("file8").Path
file9=objUpload.Files("file9").Path
file10=objUpload.Files("file10").Path

elseif g_intUploadType=1 then
set fs = CreateObject("Scripting.FileSystemObject")
if not(fs.FolderExists(strFileLocation)) then fs.CreateFolder(strFileLocation)
Set objUpload= Server.CreateObject("SoftArtisans.FileUp")
objUpload.Path=strFileLocation

objUpload.Form("file1").Save
objUpload.Form("file2").Save
objUpload.Form("file3").Save
objUpload.Form("file4").Save
objUpload.Form("file5").Save
objUpload.Form("file6").Save
objUpload.Form("file7").Save
objUpload.Form("file8").Save
objUpload.Form("file9").Save
objUpload.Form("file10").Save

file1=objUpload.Form("file1").ServerName
file2=objUpload.Form("file2").ServerName
file3=objUpload.Form("file3").ServerName
file4=objUpload.Form("file4").ServerName
file5=objUpload.Form("file5").ServerName
file6=objUpload.Form("file6").ServerName
file7=objUpload.Form("file7").ServerName
file8=objUpload.Form("file8").ServerName
file9=objUpload.Form("file9").ServerName
file10=objUpload.Form("file10").ServerName
end if

if (Err.number<>0) then
Response.Write Err.description
end if
end sub %>

-----------------------------------------------------------------------
Và file produc_upload_images.asp

Sau đây là nội dung file
-----------------------------------------------------------------------

<!--#include file="../include/lib_init.asp"-->
<!--#include file="../include/lib_utilities.asp"-->
<!--#include file="../include/lib_manager.asp"-->
<!--#include file="../include/lib_database.asp"-->
<!--#include file="../include/lib_grid.asp"-->
<!--#include file="../include/lib_form.asp"-->
<!--#include file="../include/lib_upload.asp"-->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Upload hinh anh</title>
<link rel="stylesheet" type="text/css" href="style_manager.css">
<link rel="stylesheet" type="text/css" href="style_grid.css">
</head>

<script language="javascript" src="../ClientScripts/Utilities.js"></script>
<script language="javascript" src="../ClientScripts/Utilities_manager.js"></script>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<% g_intSubHighlight=100 %>
<!--#include file="header_product.asp"-->

<% 'main content
dim PRO_ID, PRO_IMAGE1, PRO_IMAGE2, PRO_IMAGE3, PRO_IMAGE4, PRO_IMAGE5
dim intImage, strCatImage, strFileName, strFileNameTemp, strSql
dim strAction, strName, strCaption, strTitleForm
dim strLinkBack, strLinkSave, strLinkDelete
dim intPageStatus
dim strGetImage, strTmpCatImage

PRO_ID=getNumberValid(Request("PRO_ID"),0)
if (PRO_ID=0) then Response.Redirect "default.asp"

intImage=getNumberValid(Request("image_id"),0)

strAction="product_upload_image.asp?image_id=" & intImage & "&pro_id=" & PRO_ID
strTitleForm="Upload hinh anh"
strLinkBack="product_upload_list.asp?pro_id=" & PRO_ID
strLinkSave="product_upload_list.asp?pro_id=" & PRO_ID

if intImage<>6 then
strSql=" SELECT PRO_IMAGE" & intImage & " FROM SHOPASP_PRODUCT WHERE PRO_ID=" & PRO_ID
strFileName=getSingleValue(strSql)
strFileNameTemp=strFileName
end if

if Request.ServerVariables("request_method")="POST" then
call uploadFileLocal(g_intUploadType)
call saveDatabase()
else
Select case intImage
Case 1 strTmpCatImage="Hình minh họa nhỏ"
Case 2 strTmpCatImage="Hình minh họa lớn"
Case 3 strTmpCatImage="Hình ảnh chi tiết"
Case 4 strTmpCatImage="Hình ảnh 4"
Case 5 strTmpCatImage="Hình ảnh 5"
Case 6 strTmpCatImage="File kèm theo file HTML"
End Select

call showProduct(PRO_ID)
call showForm()
end if
%>

<!--#include file="footer.asp"-->

<% 'showForm()
sub showForm() %>
<table border="0" cellspacing="1" cellpadding="3" class="tdGridTable" align="center">
<form action="<%=strAction%>" ENCTYPE="MULTIPART/FORM-DATA" method="POST" name="frmUpload" id="frmUpload">
<tr>
<td class="tdGridTitle" colspan="2">
<%=strTitleForm%>
<% if not(IsNaS(strLinkBack)) then %>&nbsp;<a href="<%=strLinkBack%>"><span class="linkAdd">Back</span></a> <% end if %>
</td>
</tr>
<tr class="tdGridRow">
<td><b><%call showStringUnicode(strTmpCatImage)%>:</b></td>
<td><input type="file" name="strFileName" id="strFileName" size="50" onchange="InsertImage(this)"></td>
</tr>
<% dim path: path=getPathProduct(PRO_ID)%>
<% call showFieldInput (strTmpCatImage & " (local):", "IMAGE_LOCAL", "image", "", "", 0, 0 , 0, false, false, false) %>
<% call showFieldInput (strTmpCatImage & ":", "IMAGE_SERVER", "image", "", path & strFileName, 0, 0 , 0, false, false, false) %>
<tr>
<td class="tdGridTitle" colspan="2">
<% call showSaveResetBackButton()%>
</td>
</tr>
</form>
</table>
<% end sub %>

<% 'uploadFileLocal
sub uploadFileLocal(intUploadType)
dim strFilePath, strFileLocation

strFilePath=getPathProduct(PRO_ID)
strFileLocation=Server.MapPath(strFilePath)

if (strFileName<>"") then call delFile(strFileLocation & "" & strFileName)
call uploadFile(strFileName, strFileLocation, intUploadType)
strFileName=Mid(strFileName,InStrRev(strFileName," ")+1)

end sub %>


<% 'saveDatabase()
sub saveDatabase()
dim sqlSave
if intImage<>6 then
sqlSave = "UPDATE SHOPASP_PRODUCT SET " & _
" PRO_IMAGE" & intImage & "=" & CDBStr(strFileName) & _
" WHERE PRO_ID=" & PRO_ID
call execSQL(sqlSave)
end if
Response.Redirect strLinkSave
end sub %>

</body>
</html>


<script LANGUAGE="javascript">
function InsertImage(txtFile, intImage)
{
var imgPath;
imgPath=txtFile.value;
document.IMAGE_LOCAL.src=imgPath;
}
</script>

---------------------------------------------------------------------

Trong file lib_upload.asp trên là dùng chung cho tất cả các định dạng. Nhưng trong trang quản trị thì mổi định dạng đều có mộ file
upload_produc_htlm.asp dùng để Up file *.html

Mong các cao thủ xuất chiêu chỉ giáo dùm.
real_time viết 12:16 ngày 10/10/2018
đâu? tui có thấy gì đâu? mà dinhbaochau chắc file upload bị làm sao thôi. Hoặc là ông cho everyone có quyền đọc ghi trên thư mục đó đi.

ối trời ơi nhìn vào hoa cả mắt luôn bác đánh dấu cho em line 17 đó nằm đâu và tên lỗi như nào may ra em còn đoán được chứ bác đưa cả đống đó lên thế này thì đến bố em cũng không thể biết được. mà nhất là thông báo lỗi gì chi tiết càng tốt (à nếu có cái error number ấy bác đưa ra được là tốt nhất.)
dinhbaochau viết 12:24 ngày 10/10/2018
Nó báo lỗi ở đây nè

set objUpload= Server.CreateObject("Persits.Upload.1")
dinhbaochau viết 12:22 ngày 10/10/2018
Lổi nó như thế này đây!
-----------------------------------------------------------------------------------

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

--------------------------------------------------------------------------------

Please try the following:

Click the Refresh button, or try again later.

Open the localhost home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid class string
/phuongnam/include/lib_upload.asp, line 17


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705)

Page:
POST 4464 bytes to /phuongnam/pncquantrithongtin/product_upload_image.asp

POST Data:
. . .

Time:
Tuesday, May 10, 2005, 9:35:09 AM


More information:
Microsoft Support

Không ai trả lời giúp sao? đang cần gấm lắm pà kon ơi!
real_time viết 12:25 ngày 10/10/2018
em nhìn vào cái đống của bác mà hoa cả mắt chẳng hiểu gì hết trơn à bác làm như này giúp em nhé được ko? em cho bác 2 page bác upload gì thoải mái upload ok chưa chứ báo thế em chào thua bác rồi.:
modMimeFunctions.asp
Code:
<%
'© 2000-2003 L.C. Enterprises
'http://LCen.com
%>
<%
'MIME Parsing Functions Module
'Author: Luis Cantero
'© 2000-2003 L.C. Enterprises
'http://LCen.com
'Updated: 08/JUN/2003


'PURPOSE:	Returns the HEADER of a Mime entry
'INPUT:		String: Mime entry
'OUTPUT:	String: Found header | Empty
Function GetMimeHeader(strMime)

	Dim intDataStart, strHeader

	'Find header boundary
	intDataStart = InStr(strMime, vbCrLf & vbCrLf)
	If intDataStart > 0 Then 'Header boundary found
		'Parse header and return
		GetMimeHeader = Left(strMime, intDataStart - 1)
	End If

End Function

'PURPOSE:	Returns an array containing the received multipart data in Mime format
'OUTPUT:	String Array | Empty
Function GetMimeArray()

	Dim strSignature, strCompleteData, lngTotalBytes, lngBytesRead, lngChunkSize, objSourceData

	'Initialize
	lngChunkSize = 5242880 '5 MB
	lngBytesRead = 0

	If Request.ServerVariables("REQUEST_METHOD") = "POST" And LCase(Left(Request.ServerVariables("HTTP_Content_Type"), 19)) = "multipart/form-data" Then
		lngTotalBytes = Request.TotalBytes

		Set objSourceData = CreateObject("ADODB.Stream")
		objSourceData.Open
		objSourceData.Type = 1 'Binary

		Do While lngBytesRead < lngTotalBytes And Response.IsClientConnected
			'Adjust chunk's length before reading
			If lngChunkSize + lngBytesRead > lngTotalBytes Then lngChunkSize = lngTotalBytes - lngBytesRead

			'Read chunk of data
			objSourceData.Write(Request.BinaryRead(lngChunkSize))

			'Increase read counter
			lngBytesRead = lngBytesRead + lngChunkSize
		Loop

		'Convert binary string to real string
		objSourceData.Position = 0
		strCompleteData = GetStringFromBinary(objSourceData.Read)

		Set objSourceData = Nothing

		'Parse Signature (file separator)
		strSignature = Left(strCompleteData, InStr(strCompleteData, vbCrLf) + 1)

		strCompleteData = Mid(strCompleteData, InStr(strCompleteData, vbCrLf) + 2, Len(strCompleteData) - 2 - 2 * Len(strSignature))

		'Put files into a string Array and return
		GetMimeArray = Split(strCompleteData, strSignature)
	Else 'Return empty array
		GetMimeArray = Split("")
	End If

End Function

'PURPOSE:	Converts a multibyte or binary string (VT_UI1 | VT_ARRAY) to a real string (BSTR) using an ADO Recordset
'INPUT:		String: MultiByte or Binary string
'OUTPUT:	String: Real string
Function GetStringFromBinary(strBinaryData)

	Dim Rs, lngBinaryLength
	Const adLongVarChar = 201

	lngBinaryLength = LenB(strBinaryData)

	'Error check
	If lngBinaryLength = 0 Then Exit Function

	'MultiByte data must be converted To VT_UI1 | VT_ARRAY first
	If VarType(strBinaryData) = 8 Then strBinaryData = MultiByteToBinary(strBinaryData)

	Set Rs = CreateObject("ADODB.Recordset")

	Rs.Fields.Append "tmpBinField", adLongVarChar, lngBinaryLength 'Create temp field
	Rs.Open
	Rs.AddNew
	Rs("tmpBinField").AppendChunk strBinaryData	'Add binary data to temp table
	Rs.Update

	GetStringFromBinary = Rs("tmpBinField") 'Get string and return it

	Set Rs = Nothing

End Function

'PURPOSE:	Converts a multibyte string to real binary data (VT_UI1 | VT_ARRAY) using an ADO Recordset
'INPUT:		String: MultiByte string
'OUTPUT:	String: Real binary string
Function GetBinaryFromMultiByte(strMultiByte)

	Dim Rs, lngMultiByteLength
	Const adLongVarBinary = 205

	lngMultiByteLength = LenB(strMultiByte)

	'Error check
	If lngMultiByteLength = 0 Then Exit Function

	Set Rs = CreateObject("ADODB.Recordset")

	Rs.Fields.Append "tmpBinField", adLongVarBinary, lngMultiByteLength 'Create temp field
	Rs.Open
	Rs.AddNew
	Rs("tmpBinField").AppendChunk strMultiByte & ChrB(0) 'Add multibyte data to temp table
	Rs.Update

	GetBinaryFromMultiByte = Rs("tmpBinField").GetChunk(lngMultiByteLength) 'Get binary data and return it

	Set Rs = Nothing

End Function

'PURPOSE:	Returns the "Content-Disposition" of a Mime entry
'INPUT:		String: Mime entry
'OUTPUT:	String: Found content-disposition | Empty
Function GetMimeContentDisposition(strMime)

	GetMimeContentDisposition = GetMimeValueByCoord(strMime, "Content-Disposition:", ";")

End Function

'PURPOSE:	Returns the "Content-Type" of a Mime entry
'INPUT:		String: Mime entry
'OUTPUT:	String: Found content-type | Empty
Function GetMimeContentType(strMime)

	GetMimeContentType = GetMimeValueByCoord(strMime, "Content-Type:", vbCrLf)

End Function

'PURPOSE:	Returns the "filename" of a Mime entry
'INPUT:		String: Mime entry
'OUTPUT:	String: Found filename | Empty
Function GetMimeFilename(strMime)

	GetMimeFilename = GetMimeValueByCoord(strMime, "filename=""", """")

End Function

'PURPOSE:	Returns the "name" of a Mime entry
'INPUT:		String: Mime entry
'OUTPUT:	String: Found name | Empty
Function GetMimeName(strMime)

	GetMimeName = GetMimeValueByCoord(strMime, "name=""", """")

End Function

'PURPOSE:	Returns the value of an ENTRY of a Mime entry
'INPUT:		String: Mime entry
'OUTPUT:	String: Found value | Empty
Function GetMimeValue(strMime)

	Dim intBeg

	'Search for left boundary
	intBeg = InStr(1, strMime, vbCrLf & vbCrLf) + Len(vbCrLf & vbCrLf)

	If intBeg > 0 Then
		'Return found value
		GetMimeValue = Mid(strMime, intBeg, Len(strMime) - intBeg - 1)
	End If

End Function

'PURPOSE:	Returns the value of a VARIABLE of a Mime entry
'INPUT:		String: Mime entry, String: Left and right bounds
'OUTPUT:	String: Found value | Empty
Function GetMimeValueByCoord(strMime, strLeftBound, strRightBound)

	Dim intBeg, intEnd, strHeader

	'Get header
	strHeader = GetMimeHeader(strMime)

	'Search for value name in header
	intBeg = InStr(1, strHeader, strLeftBound)

	If intBeg > 0 Then	 'Value name found in header, parse value
		intBeg = intBeg + Len(strLeftBound)
		intEnd = InStr(intBeg, strMime, strRightBound)

		If intEnd = 0 Then intEnd = Len(strMime)

		'Return found value
		GetMimeValueByCoord = Trim(Mid(strMime, intBeg, intEnd - intBeg))
	End If

End Function

'PURPOSE:	Returns the value of an ENTRY in the Mime array, according to it's NAME
'INPUT:		Array: Mime array, String: Name of the value to be retrieved
'OUTPUT:	String: Found value | Empty
Function GetMimeValueByName(arrMime, strValueName)

	Dim intI, intBeg, strHeader

	'Search all items of array
	For intI = 0 To UBound(arrMime)

		'Get header
		strHeader = GetMimeHeader(arrMime(intI))
		If strHeader <> "" Then 'Header found
			'Search for value name in header
			intBeg = InStr(1, strHeader, "name=""" & strValueName & """")
			If intBeg > 0 Then 'Value name found in header, parse value
				intBeg = intBeg + Len("name=""" & strValueName & """") + Len(vbCrLf & vbCrLf)

				'Return found value
				GetMimeValueByName = Mid(arrMime(intI), intBeg, Len(arrMime(intI)) - intBeg - 1)
				Exit For
			End If
		End If
	Next

End Function

'PURPOSE:	Extracts the name of a file from its path
'INPUT:		String: Path
'OUTPUT:	String: Name
Function GetFilenameFromPath(strPath)

	Dim intI

	intI = InStrRev(strPath, "\")
	If intI > 0 Then
		GetFilenameFromPath = Mid(strPath, intI + 1)
	Else
		GetFilenameFromPath = strPath
	End If

End Function

'PURPOSE:	Saves a file using the FileSystemObject
'INPUT:		String: files's contents, String: save path
Sub WriteFile(strFileData, strSavePath)

	Dim objFSO, objTextStream

	If Len(strFileData) = 0 Then Exit Sub

	'Create objects
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objTextStream = objFSO.CreateTextFile(strSavePath, True, False)

	'Write file and close it
	objTextStream.Write strFileData
	objTextStream.Close

	'Delete objects
	Set objTextStream = Nothing
	Set objFSO = Nothing

End Sub

'PURPOSE:	Deletes a file using the FileSystemObject
'INPUT:		String: files's path
Sub DeleteFile(strPath)

	Dim objFSO, tmpFileHandle

	'Create object
	Set objFSO = CreateObject("Scripting.FileSystemObject")

	'Delete zoom image
	If objFSO.FileExists(strPath) Then
		Set tmpFileHandle = objFSO.GetFile(strPath)
	 	tmpFileHandle.Delete
	End If

	'Delete objects
	Set tmpFileHandle = Nothing
	Set objFSO = Nothing

End Sub

'PURPOSE:	Generates a "Unique Random Filename" to save uploaded files
'INPUT:		String: Name of uploaded file
'OUTPUT:	String: Unique random filename in this format: Date_RandomNumber.EXT
'NOTES:		RandomNumber = Round(RND * 1000000), Extension is kept
Function GenerateRandomName(strFileName)

	Dim strDate

	'Remove illegal characters for a filename
	strDate = Year(Now) & "." & String(2 - Len(Month(Now)), "0") & Month(Now) & "." & String(2 - Len(Day(Now)), "0") & Day(Now)

	Randomize

	'Return
	GenerateRandomName = strDate & "_" & CStr(Round(Rnd * 1000000)) & Mid(strFileName, InStrRev(strFileName, ".")) 'Date_RandomNumber.EXT

End Function

'PURPOSE:	Rounds a Byte amount and returns KB with 2 decimal places
'INPUT:		Long: Byte amount
'OUTPUT:	String: Rounded KB amount
Function GetRoundedKB(lngByteAmount)

	GetRoundedKB = FormatNumber(Int(lngByteAmount / 1024 * 100 + 0.5) / 100, 2)

End Function

'PURPOSE:	Rounds a Byte amount and returns, according to an elapsed time in seconds, KB/s with 2 decimal places
'INPUT:		Long: Byte amount
'OUTPUT:	String: Rounded KB/s amount
Function GetRoundedKBperS(lngByteAmount, lngSecondsElapsed)

	'Error check
	If lngSecondsElapsed <= 0 Then lngSecondsElapsed = 1

	GetRoundedKBperS = FormatNumber(Int(lngByteAmount / 1024 / lngSecondsElapsed * 100 + 0.5) / 100, 2)

End Function

%>
upload.asp
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'© 2000-2003 L.C. Enterprises
'http://LCen.com
%>
<%
	Option Explicit
	Response.Expires = 0

	'CONFIGURATION BEGIN	***********************
	Server.ScriptTimeout = 1000					'Time-out limit for the file upload in seconds
	Const lngUploadLimit = 30000000				'File size limit in Bytes
	Const strPageToContinue = "TargetPage.asp"	'Name of the page to which the received variables should be posted/redirected
	Const intTypeOfPageContinue = 0				'What to do after the upload is complete: 0 = Do nothing / 1 = Post variables to continue page / 2 = Redirect
	Const strUploadFolder = "Uploaded/"
	Const intVerbose = 1						'Display info about uploaded file(s): 0 = No / 1 = Yes
	'CONFIGURATION END		***********************
%>
<!--#INCLUDE FILE="modMimeFunctions.asp" -->
<%
Dim strDate
strDate = Now()

Response.Write "<BR>Upload started: " & strDate & "<BR>"

Dim lngBytesReceived, arrMimeData, lngItemIndex
Dim strActualFileOrValue, strSaveName

Dim strName

lngBytesReceived = Request.TotalBytes

If lngBytesReceived > lngUploadLimit Then
	Response.Write("<DIV ALIGN=""CENTER""><B>Sorry, your request cannot be completed because:<BR><BR>Maximum allowed size for the file is " & GetRoundedKB(lngUploadLimit) & " KB. Your request: " & GetRoundedKB(lngBytesReceived) & " KB</DIV>")
	Response.Write("<META HTTP-EQUIV=""REFRESH"" CONTENT=""3; URL=javascript:history.go(-1)"">")
	Response.End
End If

If lngBytesReceived > 0 Then 'Data has been received
	%>
		<DIV ALIGN="CENTER"><IMG SRC="images/processing.gif"><BR>File is uploading... Please wait...</DIV>
		<FORM NAME="frmUpload">
	<%
	'Put files into a String Array
	arrMimeData = GetMimeArray()

	'Loop for every file in the Array
	For lngItemIndex = 0 To UBound(arrMimeData)

		'Get file or value
		strActualFileOrValue = GetMimeValue(arrMimeData(lngItemIndex))

		If GetMimeContentType(arrMimeData(lngItemIndex)) = "" Or GetMimeFilename(arrMimeData(lngItemIndex)) = "" Then 'No Content-type Or filename found

			strName = GetMimeName(arrMimeData(lngItemIndex))

			'Write form name and value, make sure it is safe for posting
			Response.Write("<INPUT TYPE=""HIDDEN"" NAME=""" & strName & """ VALUE=""" & Server.HTMLEncode(strActualFileOrValue) & """>" & vbCrLf)

			'Response.Write "<B>=== ERROR: Not a file</B><BR>"
			'Response.Write "--- Data Submitted: <B>" & strActualFileOrValue & "</B>"
			'Response.Write " (Length=" & Len(strActualFileOrValue) & ")<BR>"

		Else 'Content-type and filename found

			'Get the name of the variable
			strName = GetMimeName(arrMimeData(lngItemIndex))
			'strSaveName = GetFilenameFromPath(GetMimeFilename(arrMimeData(lngItemIndex))) 'Use original filename

			'Generate unique name, extension is kept
			strSaveName = GenerateRandomName(strSaveName)

			Response.Write("<INPUT TYPE=""HIDDEN"" NAME=""" & strName & """ VALUE=""" & strSaveName & """>" & vbCrLf)

			Call WriteFile(strActualFileOrValue, Server.MapPath(strUploadFolder & strSaveName))
			If intVerbose = 1 Then Response.Write("<FONT COLOR=""RED"">" & strSaveName & "</FONT> (" & GetRoundedKB(Len(strActualFileOrValue)) & " KB)<BR>")

		End If
	Next
End If

'All done, now redirect
Response.Write "<BR><BR>Upload complete: " & Now()
Response.Write "<BR>Speed: " & GetRoundedKBperS(lngBytesReceived, DateDiff("s", strDate, Now())) & " KB/s"
%>
<SCRIPT>
<!--
	<%
	Select Case intTypeOfPageContinue
		Case 0 'Do nothing

		Case 1 'Post variables to continue page
			%>
				document.forms[0].action = "<%=strPageToContinue%>";
				document.forms[0].method = "POST";
				document.forms[0].submit();
			<%

		Case 2 'Redirect
			%>
				window.location.href = "<%=strPageToContinue%>";
			<%
	End Select
	%>
// -->
</SCRIPT>
upload.htm
Code:
<HTML>
<HEAD>
<TITLE>File upload test form</TITLE>
</HEAD>
<BODY>
<FORM ACTION="upload.asp" METHOD="POST" ENCTYPE="multipart/form-data" NAME="Form1" onSubmit="return OnFilesSubmitted()">
  <P>
    <INPUT NAME="File1" TYPE="File">
    <BR>
  </P>
  <P>
	<INPUT NAME="File2" TYPE="File">
  </P>
  <P>
	<INPUT NAME="File3" TYPE="File">
  </P>
  <P>
	<INPUT NAME="File4" TYPE="File">
  </P>
  <P>
	<INPUT NAME="File5" TYPE="File">
			<BR>
	<INPUT NAME="Submit1" TYPE="Submit">
  </P>
</FORM>
			
<DIV ALIGN="CENTER">
	<FONT COLOR="a90000" SIZE="5" FACE="verdana"><MARQUEE><P ID="MyID"></P></MARQUEE></FONT>
	<BR><IMG NAME="imgPross" BORDER="0" SRC="images/WhitePixel.gif" WIDTH="123" HEIGHT="16">
</DIV>

<SCRIPT>
	function OnFilesSubmitted()
	{
	    document.all("MyID").innerHTML = '<BR>Files are uploading... Please wait...';

		document.all.imgPross.src = imgPreload.src;
		document.all.Submit1.disabled = true;
    	return true;
	}

	var imgPreload = new Image(); //Preload image
	imgPreload.src = "images/processing.gif";
</SCRIPT>
</BODY>
</HTML>
đây là em tìm thấy trong planet-source-code.com nếu bác không chạy được có thể vào đó tìm lại.
NDThuan viết 12:16 ngày 10/10/2018
@dinhbaochau: có khi trên shared hosting có cài Persit Upload còn ở Localhost thì chưa cài nên mới bị lỗi Create Object ^_^
dinhbaochau viết 12:15 ngày 10/10/2018
Được gửi bởi NDThuan
@dinhbaochau: có khi trên shared hosting có cài Persit Upload còn ở Localhost thì chưa cài nên mới bị lỗi Create Object ^_^
Vậy thì bác NDThuan ời! cài cái thằng Persit Upload là sao? Cài như thế nào, config nó ra sao bác chỉ nốt cho tui luôn đi. Cái này tui mới nghe nói tới à.
Mong bác giúp cho.

Nếu có bác nào biết Up cho tui phát nhé, cám ơn các bác trước.
dan_mien_que viết 12:23 ngày 10/10/2018
Hello,

Persit Upload cái này là ActiveX phải mua của Artisoft (quên tên rồi).

Khi thấy cái này: set objUpload= Server.CreateObject("Persits.Upload.1")
là mình đoán ngay là ActiveX rồi.

ASP bên windows không có chức năng upload, vì vậy người ta phải mua thêm cái ActiveX này cài vô server mới upload files được.

Nếu kiếm không ra cái này bạn có thểm kiếm cái VBScript hình như gọi là pure ASP Upload cũng có thể upload ngon lành (bạn google search thử coi).
real_time viết 12:16 ngày 10/10/2018
đúng thế! nhưng mà chỉ cần mấy cái file của tôi là cũng upload được rồi mà nó không được nhanh bằng ActiveX kia nhưng khỏi mất tiền. Chạy thử mà xem.
gate2vn viết 12:16 ngày 10/10/2018
check lại nếu trên server hosting có DundasUpload thì setup lại, dùng cái đó cũng ok. Free
Bài liên quan
0