SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: ASP Coding

  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ASP Coding

    Can anyone tell me what the following ASP code does?

    Code:
    <%
    function SaveFiles(fnstrPhotoPath)
        Dim Upload, fileName, fileSize, ks, i, fileKey
    
        Set Upload = New FreeASPUpload    
    	Upload.Save(fnstrPhotoPath)
    
        SaveFiles = ""
        ks = Upload.UploadedFiles.keys
        if (UBound(ks) <> -1) then
            SaveFiles = "<B>Files uploaded:</B> "
            for each fileKey in Upload.UploadedFiles.keys
                SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) "
             next
        else
            SaveFiles = "The file name specified in the upload form does not correspond to a valid file in the system."
        end if
    end function
    
    Function ASPImageResize(fnstrSourceImagePath,fnstrResizeDestinationPath,fnNewWidth,fnNewHeight)
    	
    	Dim bitResult, Image, OrigWidth, OrigHeight, NewWidth, NewHeight
    	bitResult = false
    	
    	Set Image = Server.CreateObject("AspImage.Image")
    	Image.AutoSize = false	
    	if Image.LoadImage(fnstrSourceImagePath) then response.write "Image Loaded successfully<br />"
    	
    	OrigWidth = Image.MaxX
    	OrigHeight = Image.MaxY
    	
    	
    	if fnNewWidth = 0 or fnNewHeight = 0 then
    		fnNewWidth = OrigWidth
    		fnNewHeight = OrigHeight
    	end if
    		
    	
    	if OrigWidth > fnNewWidth or OrigHeight > fnNewHeight then
    		
    		if OrigHeight > OrigWidth then
    			NewHeight = fnNewHeight
    			NewWidth = cInt(cInt(OrigWidth) / (cInt(OrigHeight)/fnNewHeight))
    		else
    			NewWidth = fnNewWidth
    			NewHeight = cInt(cInt(OrigHeight) / (cInt(OrigWidth)/fnNewWidth))
    		end if
    		
    	end if
    	
    	Image.FileName = fnstrResizeDestinationPath
    	If Image.ImageFormat = 1 then	
    		Image.DPI = 72
    		Image.JPEGQuality = 60
    		Image.Sharpen 1
    	end if
    	
    	
    	Image.ResizeR fnNewWidth, fnNewHeight		
    	If Image.SaveImage then bitResult = true
    	
    	Set Image = Nothing
    	
    	ASPImageResize = bitResult
    End Function
    
    Sub ShowAllVintageManfs(fnselected,fnbitShowAll)
    	Call ConnectDB()
    	strSQL = "qryAdminAllVintageManfs"
    	set objRS = objDB.Execute(strSQL,,adCmdStoredProc)		
    		if fnbitShowAll then
    			response.write "<option value=""0"""
    			if fnselected = 0 then response.write " style=""background:#eee;"" selected=""selected"""
    			response.write ">All Manufacturers</option>"
    		end if
    		Do while not objRS.EOF
    			response.write "<option value=""" & objRS(0) & """"
    			if objRS(0) = fnselected then response.write " style=""background:#eee;"" selected=""selected"""
    			response.write ">" & objRS(1) & "</option>"
    			objRS.MoveNext
    		Loop
    	Call CloseRS()
    	Call CloseDB()
    End Sub
    
    Sub ShowAllPenRanges(fnselected)
    	Call ConnectDB()
    	strSQL = "qryAdminAllPenRanges"
    	set objRS = objDB.Execute(strSQL,,adCmdStoredProc)
    		Do while not objRS.EOF
    			response.write "<option value=""" & objRS(0) & """"
    			if objRS(0) = fnselected then response.write " style=""background:#eee;"" selected=""selected"""
    			response.write ">" & objRS(1) & "</option>"
    			objRS.MoveNext
    		Loop
    	Call CloseRS()
    	Call CloseDB()
    End Sub
    
    Sub ShowAllPenModes(fnselected)
    	Call ConnectDB()
    	strSQL = "qryAdminAllPenModes"
    	set objRS = objDB.Execute(strSQL,,adCmdStoredProc)
    		Do while not objRS.EOF
    			response.write "<option value=""" & objRS(0) & """"
    			if objRS(0) = fnselected then response.write " style=""background:#eee;"" selected=""selected"""
    			response.write ">" & objRS(1) & "</option>"
    			objRS.MoveNext
    		Loop
    	Call CloseRS()
    	Call CloseDB()
    End Sub
    
    Function GetManfName(fnManfID)
    	strSQL = "SELECT manfname FROM tblPenManfs WHERE ManfID=" & fnManfID
    	Call ConnectDB()	
    		set objRS = objDB.Execute(strSQL,,adCmdText)		
    		GetManfName = objRS(0)
    	Call CloseRS()
    	Call CloseDB()
    End Function
    
    Function GetRangeName(fnRangeID)
    	strSQL = "SELECT rangename FROM tblPenRanges WHERE rangeID=" & fnRangeID
    	Call ConnectDB()	
    		set objRS = objDB.Execute(strSQL,,adCmdText)
    		GetRangeName = objRS(0)
    	Call CloseRS()
    	Call CloseDB()
    End Function
    
    Function ShowCheckbox(fnBooleanVaue)
    	if cbool(fnBooleanVaue) then
    		ShowCheckbox = "<img src=""images/yes.gif"" alt=""Yes"" border=""0"" />"
    	else
    		ShowCheckbox = "<img src=""images/no.gif"" alt=""No"" border=""0"" />"
    	end if	
    End Function
    %>

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This script is very useful providing you have the components to run it. Basically you upload the file using the form provided. It uses ASPImage from Serverobjects to manipulate or create an image using asp coding. By the looks of it, its not creating an image but checking that two images match. i think..

    Have a look at:

    http://www.serverobjects.com/comp/Aspimage.htm
    Gav

  3. #3
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile ASP Coding

    Thanks Gav, It's the ASP component that missing.

  4. #4
    HardCoder md_irfan_amu's Avatar
    Join Date
    May 2005
    Location
    Asia
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is an upload script but you have to register your componrnt with servber to run this script,It is very useful,
    Irfan
    Find Tutors Easyway to get connect with your tutor in india

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just had to add a bit, it seems that what this does besides, upload, is it also resizes the image uploaded. I'm going to assume that it resizes to thumbnail size for an online catalog.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •