<% Function ConvertBytes(ByRef anBytes) Dim lnSize ' File Size To be returned Dim lsType ' Type of measurement (Bytes, KB, MB, GB, TB) Const lnBYTE = 1 Const lnKILO = 1024 ' 2^10 Const lnMEGA = 1048576 ' 2^20 Const lnGIGA = 1073741824 ' 2^30 Const lnTERA = 1099511627776 ' 2^40 ' Const lnPETA = 1.12589990684262E+15 ' 2^50 ' Const lnEXA = 1.15292150460685E+18 ' 2^60 ' Const lnZETTA = 1.18059162071741E+21 ' 2^70 ' Const lnYOTTA = 1.20892581961463E+24 ' 2^80 If anBytes = "" Or Not IsNumeric(anBytes) Then Exit Function If anBytes < 0 Then Exit Function ' If anBytes < lnKILO Then ' ' ByteConversion ' lnSize = anBytes ' lsType = "bytes" ' Else If anBytes < lnMEGA Then ' KiloByte Conversion lnSize = (anBytes / lnKILO) lsType = "kb" ElseIf anBytes < lnGIGA Then ' MegaByte Conversion lnSize = (anBytes / lnMEGA) lsType = "mb" ElseIf anBytes < lnTERA Then ' GigaByte Conversion lnSize = (anBytes / lnGIGA) lsType = "gb" Else ' TeraByte Conversion lnSize = (anBytes / lnTERA) lsType = "tb" End If ' End If ' Remove fraction 'lnSize = CLng(lnSize) lnSize = FormatNumber(lnSize, 2, True, False, True) ' Return the results ConvertBytes = lnSize & " " & lsType End Function '<-----------------------จบส่วนฟังก์ชั่นที่เพิ่มเข้าไป---------------------------> ' Variables ' ********* Dim mySmartUpload Dim file Dim intCount intCount=0 ' Object creation ' *************** Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") ' Upload ' ****** mySmartUpload.Upload ' Select each file ' **************** For each file In mySmartUpload.Files ' Only if the file exist ' ********************** If not file.IsMissing Then ' Save the files with his original names in a virtual path of the web server ' **************************************************************************** file.SaveAs(Server.MapPath("Upload/" & file.FileName)) ' sample with a physical path ' file.SaveAs("c:\temp\" & file.FileName) Size1 = ConvertBytes(file.Size) '<------ สั่งให้คำนวน ' Display the properties of the current file ' ****************************************** Response.Write("Name = " & file.Name & "<BR>") Response.Write("Size = " & Size1 & "<BR>") '<------ แสดงขนาดที่คำนวนแล้ว Response.Write("FileName = " & file.FileName & "<BR>") Response.Write("FileExt = " & file.FileExt & "<BR>") Response.Write("FilePathName = " & file.FilePathName & "<BR>") Response.Write("ContentType = " & file.ContentType & "<BR>") Response.Write("ContentDisp = " & file.ContentDisp & "<BR>") Response.Write("TypeMIME = " & file.TypeMIME & "<BR>") Response.Write("SubTypeMIME = " & file.SubTypeMIME & "<BR>") intCount = intCount + 1 End If Next ' Display the number of files which could be uploaded ' *************************************************** Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>") ' Display the number of files uploaded ' ************************************ Response.Write(intCount & " file(s) uploaded.<BR>") %>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง