logo
Tags down

shadow

Syntax error in Classic ASP file with server-side-include


By : DMuze
Date : September 15 2020, 08:00 PM
will help you Your UserHeader.asp file will contain a mismatched or broken control-flow statement.
Server-side-includes are evaluated before the VBScript interpreter runs.
code :


Share : facebook icon twitter icon

Classic ASP with Server-Side Javascript, calling function in a different file


By : user3550903
Date : March 29 2020, 07:55 AM
To fix the issue you can do I may be wrong but I don't think you can use include files in this manner. I have never seen include files dynamically added this way.
Try
code :
function shouldLink(filename)
{
    filename = "a.asp";
    var splits = filename.split(".");
    var file = splits[0].toUpperCase() + "_ShouldLink()";  // A_ShouldLink() function  name built here

   Server.Execute(fliename) 
   var exec =  "eval( " + file + " );";

   try{
          return eval( exec );
   } catch( err ){

   }

   return true;

How do you include a javascript file on the server side using classic ASP?


By : Geezerette
Date : March 29 2020, 07:55 AM
Does that help
Please note - I am not ignoring the fact that JScript can be used in the browser as per the excellent info on this answer: What's the difference between JavaScript and JScript?. This question clearly is talking about JScript in the context of the server, so from here on the term 'JScript' means the version(s) of JScript that are used in ASP or in Windows scripting

how to run server side exe file from classic asp for non IE browser


By : Vanessa Sharma
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Your browser doesn't have anything to do with that, as this is server-side. On the server , you could try this :
code :
<%
Set WshShell = Server.CreateObject("WScript.Shell") 
WshShell.Run "c:\windows\notepad.exe"
Set WshShell= nothing
%>

Why is the classic ASP server-side include enclosed in a comment?


By : JamesJudge.info
Date : March 29 2020, 07:55 AM
With these it helps I think the main reason is the server side processing in the case of server side includes is handled directly by IIS then passed off to the processing engine the content is related to.
So using the example in the question, if the syntax was;
code :
<% #include file="suchandsuch" %>

How do I reference an uploaded file in a server-side Classic ASP page?


By : user2553806
Date : March 29 2020, 07:55 AM
may help you . Once a file has been uploaded you could use FileSystemObject to check the file exists and retrieve its properties via the GetFile method. Use a function to save space and return a dictionary of properties, making them easier to reference:
code :
function getFileInfo(ByVal fileLocation)

    ' Use MapPath to convert to an absolute path

    fileLocation = Server.MapPath(fileLocation)

    ' Set the file system and dictionary objects using reserved words

    set fileSystem = Server.CreateObject("Scripting.FileSystemObject")
    Set dictionary = Server.CreateObject("Scripting.Dictionary")

    ' Check that the file exists

    if fileSystem.FileExists(fileLocation) then

        ' Use GetFile to retrieve the files properties

        set file = fileSystem.GetFile(fileLocation)

        ' Add each property to the dictionary object

        dictionary.add "FileFound",true
        dictionary.add "Attributes",file.Attributes
        dictionary.add "DateCreated",file.DateCreated
        dictionary.add "DateLastAccessed",file.DateLastAccessed
        dictionary.add "DateLastModified",file.DateLastModified
        dictionary.add "Drive",file.Drive
        dictionary.add "Name",file.Name
        dictionary.add "ParentFolder",file.ParentFolder
        dictionary.add "Path",file.Path
        dictionary.add "ShortName",file.ShortName
        dictionary.add "ShortPath",file.ShortPath
        dictionary.add "Size",file.Size
        dictionary.add "Type",file.Type

        ' Attributes translations:
        ' 0 = Normal file
        ' 1 = Read-only file
        ' 2 = Hidden file
        ' 4 = System file
        ' 16 = Folder or directory
        ' 32 = File has changed since last backup
        ' 1024 = Link or shortcut
        ' 2048 = Compressed file

    else

        ' File not found

        dictionary.add "FileFound",false

    end if

    ' Return the dictionary object

    set getFileInfo = dictionary

    ' Set all objects to nothing

    set fileSystem = nothing
    set dictionary = nothing
    set file = nothing

end function
Dim fileInfo : Set fileInfo = getFileInfo("../../uploads/cat.jpg")  

    ' getFileInfo("/Images/" & upl.Form ("id") & ".jpg") 

    if fileInfo.item("FileFound") then

        ' Output all the file properties

        for each item in fileInfo
            response.write "<b>" & item & "</b>: " & fileInfo.item(item) & "<br>"
        next

        ' Output a specific file property

        response.write "<b>The file size is</b>: " & fileInfo.item("Size") & " bytes<br>"
        response.write "<b>The file type is</b>: " & fileInfo.item("Type") & "<br>"

    else

        response.write "File not found"

    end if

Set fileInfo = nothing
function randomFileName()

    ' Randomize() generates quite a small seed number, so you will generate duplicate
    ' filenames if you upload enough images. To prevent this, prefix a random number
    ' with a unix timestamp.

    Dim uts : uts = DateDiff("s","1970-01-01 00:00:00",Now())

    Randomize()

    ' filename format: [unix timestamp][random 7 digit number]

    randomFileName = cStr(uts & Int((9999999-1000000+1)*Rnd+1000000))

end function

function validExtension(ByVal allowed, ByVal fileName)

    Dim extRegexp : Set extRegexp = New RegExp

    extRegexp.Pattern = "^.*\.(" & lCase(allowed) & ")$"
    validExtension = extRegexp.Test(lCase(fileName))

end function

if Request.TotalBytes > 0 then

    Const max_upload_size = 100000 ' bytes
    Const allowed_extensions = "jpg|jpeg|png"
    Const upload_folder = "/Images/"

    Dim upload_successful : upload_successful = false
    Dim upload_message : upload_message = ""
    Dim rndFileName, fileExt, fileSplit

    Dim upl : Set upl = New FileUploader 
    upl.Upload()

    If upl.Files.Count = 1 Then

        For Each File In upl.Files.Items

            file.ContentType = lCase(file.ContentType)
            File.FileName = trim(File.FileName)

            if NOT (file.ContentType = "image/jpeg" _
            OR file.ContentType = "image/jpg" _
            OR file.ContentType = "image/png") then

                upload_message = "Invalid file type"

            elseif NOT validExtension(allowed_extensions,File.FileName) then

                upload_message = "Invalid file type"

            elseif File.FileSize > max_upload_size then

                upload_message = "File too big"

            else

                ' Extract the file extension

                fileSplit = split(File.FileName,".")
                fileExt = lCase(fileSplit(uBound(fileSplit)))

                ' Generate a random file name

                rndFileName = randomFileName() & "." & fileExt

                ' Everything checks out, save to disk

                File.FileName = rndFileName
                File.SaveToDisk Server.MapPath(upload_folder)

                upload_message = "Upload successful"

                upload_successful = true

            end if

        next

    else

        upload_message = "Maximum upload count exceeded"

    end if

    Set upl = nothing

    ' Return a JSON string      

    Response.ContentType = "application/json"

    response.write _
    "{""uploaded"":" & lCase(upload_successful) & "," &_
    """message"":""" & upload_message & """," &_
    """file"":""" & upload_folder & rndFileName & """}"

end if
shadow
Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk