Results 1 to 4 of 4

Thread: Request.Form

  1. #1
    SpYDa Guest

    Default Request.Form

    I need to be able to link to a file, but each time the file changes. <BR><BR>basically it is<BR>if strProjectFileName = request.form("Project1") then strProjectFileName = "project1.ini"<BR><BR>I just cant remember if this is correct or how to get the link

  2. #2
    Join Date
    Dec 1969

    Default RE: Request.Form

    Well, if the name of the project is always the first part of the file, you could do this:<BR><BR>FileName = request("Project") & ".ini"<BR><BR>That would give you the file name as well...<BR><BR>Erick

  3. #3
    SpYDa Guest

    Default RE: Request.Form

    i&#039m using an if then else because i use strProjectFileName to read and write to certain areas of my ini file, its just once to tell the site what file I am editing/reading

  4. #4
    r.kotecha Guest

    Default RE: Request.Form

    The request.form syntax is correct beyond that it&#039s hard to advise you because I&#039m not totally clear on the problem. As I understand you&#039re trying to link to a file that keeps changing?<BR><BR>eg: You have a file called x1.ini that changes to x2.ini and you have a webpage that linked to x1.ini and now the webpage wont work because the file has changed to x2.ini<BR><BR>If the file has a distinctive name i.e. it is the only file that begins with x in the directory or it is the only ini file in the directory then you can use the filesystemobject to search for the file and get the new name.<BR><BR>&#060;%<BR> function findfile(byref x_strSearchString)<BR> dim strPathInfo<BR> strPathInfo = request.servervariables("path_info")<BR> strPhysicalPath = server.mappath(strpathinfo)<BR><BR> dim objfso, objfile, objfolder, objfoldercontents<BR> set objfso = createobject("scripting.filesystemobject")<BR> set objfile = objfso.getfile(strPhysicalPath)<BR> set objFolder = objFile.ParentFolder<BR> set objfoldercontents = objFolder.Files<BR> Dim strFoundFileName<BR><BR> for each objfileitem in objfoldercontents<BR> if instr(, x_strSearchString) &#062; 0 then<BR> strFoundFileName =<BR> exit for<BR> end if<BR> next<BR> findfile = strFoundFileName<BR> end function<BR><BR> sub displaylink(byref x_strFilename)<BR> dim strQuote<BR> strQuote = """" <BR> response.write ("&#060;a href=" & strQuote & "http://whatever/your/link/is/" & x_strFilename & strQuote & "&#062;Here&#039s the link!&#060;/a&#062;" )<BR> end sub<BR><BR> &#039Here&#039s how you would call it:<BR> Dim strFilename<BR> strFilename = findfile(".ini") &#039you&#039re searching for a file that contains ".ini" in this case<BR> if strFilename &#060;&#062; "" then<BR> displaylink(strFilename)<BR> end if<BR>%&#062;<BR><BR>Now the chances of all this working fine first time with no debugging from you are pretty slim because:<BR>a) I didn&#039t test it<BR>b) I didn&#039t test it ;)<BR><BR>Some of it should work fine though because i copied it from a Wrox book.<BR><BR>It&#039s a start ... either way I don&#039t even know if this is going to solve your problem because your file may not have any characteristics you can search on.<BR><BR>You should not that the asp file you end up putting this code in has to be in the same directory as the file you&#039re looking for .. if this can&#039t be done you&#039ll have to modify the code a little but that shouldn&#039t be too hard.<BR><BR>Hope this helps<BR><BR>Raj<BR>( - Student Learning Resources)<BR><BR>

Posting Permissions

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