How can I pass an image parameter in HTML? Is it possible???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darin McGrew

    #16
    Re: How can I pass an image parameter in HTML? Is it possible???

    John <GodLovesEveryo ne.org@gmail.co m> wrote:[color=blue]
    > page at www.GodLovesEveryone.org/godloves.php
    >
    > When I try it in Mozilla Thunderbird, I'm getting asked if I want to
    > save the file to disk.[/color]

    That's because the server is sending the page as

    Content-Type: application/octet-stream

    rather than as

    Content-Type: text/html
    --
    Darin McGrew, darin@TheRallye Club.org, http://www.TheRallyeClub.org/
    A gimmick car rallye is not a race, but a fun puzzle testing your
    ability to follow instructions. Upcoming gimmick car rallye in
    Silicon Valley: Common Sense (Saturday, April 2)

    Comment

    • kaeli

      #17
      Re: How can I pass an image parameter in HTML? Is it possible???

      In article <1111002461.769 867.153420@l41g 2000cwc.googleg roups.com>,
      GodLovesEveryon e.org@gmail.com enlightened us with...[color=blue]
      >
      > I've left a message for him to call back. Meanwhile, I've put a test
      > page at www.GodLovesEveryone.org/godloves.php
      >
      > When I try it in Mozilla Thunderbird, I'm getting asked if I want to
      > save the file to disk.[/color]

      That one got answered. The server isn't sending the right content type. It
      needs configured.

      Whitespace is your friend. :)
      And just use GET, not POST. No need for POSTing.
      That way people can just send it in the URL, links, etc. Forms can use GET to
      send stuff, too. POST is a way forms send data, mostly, and it should really
      be used only when you're going to be doing things like updating a database.
      GET is fine (and GET is what it is when it's in the URL).

      And don't use the word "file" as a variable name. I shouldn't have -- I
      wasn't thinking.
      It's a reserved word (actually, it's a function) in PHP and you can
      inadvertently do things you don't mean to. Best to not call variable names
      the same as reserved words, even if a language allows it.

      This is better (though I might even change "$name" to "$firstname " or
      something).
      Note the shortcut for echoing a variable value or expression is <?= varname
      ?>.

      Watch for word wrap.

      <html><head>
      <?php
      $name = $HTTP_GET_VARS["name"];
      if ($name == "")
      {
      $name = "John"; // change to some default
      }
      $filename = substr($name,0, 1) . "/" . $name . ".gif";
      if (strnatcasecmp( $name,"con")) $filename = "c/con-.gif"; /* not sure why you
      have this here, what it does. */
      ?>
      <title>God Loves <?= $name ?>, a solvable puzzle personalized with
      <?= name ?>'s name.</title>
      </head>
      <body>
      [color=blue]
      >
      > <h1>God Loves <?php echo $name; ?></h1>[/color]

      <h1>God Loves <?= $name ?></h1>
      (note, when using shortcut echo, NO SEMI-COLON.)
      [color=blue]
      >
      > and when I wanted to echo the file name, either
      >
      > <img src="<?php echo $file; ?>.gif">[/color]

      You already had the .gif in there.
      <img src="<?= $filename?>">

      Note that the path was made as relative (j/john), so you have to have a
      subdir under where this file is running from matching that.
      i.e.


      [color=blue]
      >
      > One question that occurred to me when I was playing with the header is
      > if the system remembers the variables between links to the page?[/color]

      Only if you save them as session variables (requires cookies on client) or
      pass them via the URL or other means. IOW, you have to set it up to do that.
      Otherwise, no, they aren't saved.
      [color=blue]
      >
      > P.S. Just in case Brent doesn't have PHP installed, what should I tell
      > him about where to download it. You said it was free.[/color]

      PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


      One tip - PHP generates dynamic HTML. Tracing problems is often hard --
      unless you remember to view the HTML source with the browser's View->Source.
      Sometimes you find easy mistakes (like misspelled directories) there. First
      place to look when it doesn't seem to do what you thought it would. B/c the
      browser doesn't normally see PHP. All it sees (all it is supposed to see) is
      the html generated by your script.

      --
      --
      ~kaeli~
      A little rudeness and disrespect can elevate a meaningless
      interaction to a battle of wills and add drama to an
      otherwise dull day.



      Comment

      • John

        #18
        Re: How can I pass an image parameter in HTML? Is it possible???

        I found out why PHP doesn't work.

        Brent says he doesn't host PHP because it's mainly a UNIX product, and
        each time he has attempted to run PHP, it has crashed his Windows
        server.

        He suggested that I try to use either ASP or CFM, so any advice in
        those areas would be appreciated. Meanwhile, I'll see what I can find
        on a web search.

        Regarding why I have "con-.gif", it's because, for some strange reason,
        Windows won't let me have a file with "Con" as the filename, probably
        because "CON" is a reserved word, standing for CONSOLE when doing a
        display to the console, as in
        COPY filename CON: /b

        John

        Comment

        • John

          #19
          Re: How can I pass an image parameter in HTML? Is it possible???

          I've got a page mocked up in ASP that lets the user put in his name



          But I haven't figured out how to do it with URL links, can you glance
          at it and give me some advice. I did figure out how to capitalize the
          first letter of the name, and took care of that funny "Con" error.

          Here is what I ended up with, since I know you can't see it on the web
          page.

          Here's the first part of the file:

          <%@ LANGUAGE="VBSCR IPT" %>

          <% Dim First
          Dim FilNam
          First = Request.form("f irst")
          if First="" then First="John"
          First = ucase(left(Firs t,1))+mid(First ,2)
          FilNam = left(First,1)+"/"+First+".g if"
          if ucase(First)="C ON" then FilNam="C/Con-.gif"
          %>
          <HTML><HEAD>
          <TITLE>God Loves <%=First%>, a solvable puzzle personalized with
          <%=First%>'s name</title>
          </head>

          and the first H1 and image link

          <h1>God Loves <%=First%></h1>
          <img src="<%=FilNam% >">

          and the large image link

          <img src="<%=FilNam% >" width="100%">

          I'm guessing that you might be able to help me with passing parameters
          with the URL??? I also couldn't figure out how to test to see if the
          file existed. DIR$ is the function I'm used to, I couldn't find either
          it or anything starting with file like in your File_Exists example.

          I do appreciate all your help, even all the "wasted time" on PHP helped
          me get this one done much faster.

          By the way, I didn't think your name was there, but I tested the page
          with KAELI and guess what popped up? Hope that's a small thank you.

          John

          Comment

          • John

            #20
            Re: How can I pass an image parameter in HTML? Is it possible???

            Hi, Kaeli,

            In addition to the page that is "mostly working", I'm trying to work on
            a slightly different version to strip out spaces and other
            non-dash-non-letter characters from the filename, and possibly display
            two mazes if they happen to put in a name with a space, first and all.

            BUT I'm getting page not found, and getting no errors at all when I try
            to load that particular page. Here is the ASP code if you can see
            what's causing the error. I've tried breaking down the statements,
            changing OR to +, and a few other strange things, so I may have made it
            worse.

            Here it is:

            <%@ LANGUAGE="VBSCR IPT" %>

            <% Dim First
            Dim FilNam
            Dim FilNam2
            Dim i
            Dim j
            Dim FilNam3
            Dim FilNam4
            First = trim(Request.fo rm("first"))
            if First<"A" then First="John"
            if First>"zza" then First="John"
            First = ucase(left(Firs t,1))+mid(First ,2)
            FilNam = left(First,1)+"/"+First+".g if"
            if ucase(First)="C ON" then FilNam="C/Con-.gif"
            FilNam2 = left(First,1)+"/"+left$(First,i nstr(First+" "," ")-1)+".gif"
            for i=len(FilNam)-4 to 3 step -1
            j=asc(ucase(mid (FilNam,i,1)))
            if j<>45 then
            if (j<65)+(j>90) then FilNam=left(Fil Nam,i-1)+mid(FilNam,i +1)
            end if
            next
            if FilNam2<>FilNam then
            FilNam3="<img src="+chr$(34)+ FilNam2+chr$(34 )+"><P>"
            FilNam4=left$(F ilNam3,len(FilN am3)-4)+" width=100%><P>"
            end if
            %>
            <HTML><HEAD>
            <TITLE>God Loves <%=First%>, a solvable puzzle personalized with
            <%=First%>'s name</title>
            </head>
            <BODY><CENTER >
            ... snip ...
            <Table bgcolor=#ffff77 ">
            <TR><TD align=center>
            <form action="godlove s3.asp" name="form" method="post">
            <BIG>Make a Maze</big><BR>
            containing<BR>
            <I><B>Your</b></i> name:<BR><input type="text" size=15 name="first"
            />
            <p><input type="submit" value="Make My Maze">
            </form>
            <B><font size=3 color=#FF0000>& nbsp;Now</font> <font size=2> more
            than</font> <font color=#ff0000 size=3>38,000&n bsp;</font><BR>differ ent
            names</b></font>
            </td></tr></table>
            ... snip ...
            <h1>God Loves <%=First%></h1>
            <img src="<%=FilNam% >"><P>
            <%=FilNam3%>
            ... snip ...
            <h1>God Loves <%=First%></h1>
            ... snip ...
            <%=FilNam4%>
            <img src="<%=FilNam% >" width="100%">

            the occurrence of <%=FilNam3%> and 4%> should, most of the time, just
            result in a null string, but when the user puts in "JOHN WILLIAM" for
            example, it should attempt to load both "JOHN" and "JOHNWILLIA M" .

            I'm flummoxed, and I have to get up early tomorrow for an important
            meeting (keep me in your prayers, it's an important meeting), so I'm
            quitting now.

            Meanwhile, I'm very grateful for the help. I have already linked the
            new page to my main web page, www.GodLovesEveryone.org, so the page
            that is working that you helped me with is now available
            (www.GodLovesEveryone.org/godloves2.asp).

            The page that isn't working is www.godloveseveryone.org/godloves3.asp

            Thanks again.

            John

            Comment

            • kaeli

              #21
              Re: How can I pass an image parameter in HTML? Is it possible???

              In article <1111030071.906 330.255520@z14g 2000cwz.googleg roups.com>,
              GodLovesEveryon e.org@gmail.com enlightened us with...[color=blue]
              > <%@ LANGUAGE="VBSCR IPT" %>
              >
              > <% Dim First
              > Dim FilNam
              > First = Request.form("f irst")[/color]

              That's for form submissions (i.e.POST).
              You want querystring for ASP URL params.
              First = Request.QuerySt ring("first")
              [color=blue]
              >
              > I'm guessing that you might be able to help me with passing parameters
              > with the URL???[/color]

              Just link like

              [color=blue]
              > I also couldn't figure out how to test to see if the
              > file existed. DIR$ is the function I'm used to, I couldn't find either
              > it or anything starting with file like in your File_Exists example.
              >[/color]

              No, for VBScript you want FileSystemObjec t, I believe.
              Lemme go look...
              Yup.
              Set filesys = CreateObject("S cripting.FileSy stemObject")
              If filesys.FileExi sts(path) Then
              End If

              See:


              Note: vbscript syntax and functions are pretty much the same as full VB. Some
              minor differences, but nothing that should screw up something this small.
              [color=blue]
              > I do appreciate all your help, even all the "wasted time" on PHP helped
              > me get this one done much faster.
              >[/color]

              Hey, no problem.
              [color=blue]
              > By the way, I didn't think your name was there, but I tested the page
              > with KAELI and guess what popped up? Hope that's a small thank you.
              >[/color]

              Thanks. :)

              --
              --
              ~kaeli~



              Comment

              • kaeli

                #22
                Re: How can I pass an image parameter in HTML? Is it possible???

                In article <1111039388.563 297.166010@l41g 2000cwc.googleg roups.com>,
                GodLovesEveryon e.org@gmail.com enlightened us with...[color=blue]
                > Hi, Kaeli,
                >
                > In addition to the page that is "mostly working", I'm trying to work on
                > a slightly different version to strip out spaces and other
                > non-dash-non-letter characters from the filename, and possibly display
                > two mazes if they happen to put in a name with a space, first and all.[/color]

                A space is not a valid character in the URL. It would be encoded as %20.
                [color=blue]
                >
                > BUT I'm getting page not found, and getting no errors at all when I try
                > to load that particular page. Here is the ASP code if you can see
                > what's causing the error. I've tried breaking down the statements,
                > changing OR to +,[/color]

                VBScript/VB does not support/overload the plus operator (+) for string
                concatenation.
                It's an ampersand. (&)

                You might want to peruse the documentation. It has the operators in there.

                [color=blue]
                > First = trim(Request.fo rm("first"))
                > if First<"A" then First="John"[/color]

                I'm not sure if this is really what you want.
                Many languages will convert this to number comparisons, but VB isn't the
                brightest thing I've ever used. You may want to see what other string
                functions might do a better job.
                It looks like you're trying to make sure the name is an alphabetic string.

                Google is my friend. :)

                <%
                Private Function IsAlpha(byVal string)
                dim regExp, match, i, spec
                For i = 1 to Len( string )
                spec = Mid(string, i, 1)
                Set regExp = New RegExp
                regExp.Global = True
                regExp.IgnoreCa se = True
                regExp.Pattern = "[A-Z]|[a-z]|\s|[_]"
                set match = regExp.Execute( spec)
                If match.count = 0 then
                IsAlpha = False
                Exit Function
                End If
                Set regExp = Nothing
                Next
                IsAlpha = True
                End Function

                If IsNull(First) Or IsEmpty(First) Or Not IsAlpha(First)
                First = "John"
                End If
                %>
                [color=blue]
                > FilNam2 = left(First,1)+"/"+left$(First,i nstr(First+" "," ")-1)+".gif"[/color]

                Ampersands. Not pluses. And take out the dollar sign.

                FilNam2 = left(First,1) & "/"+left(First,in str(First+" "," ")-1) & ".gif"
                [color=blue]
                > for i=len(FilNam)-4 to 3 step -1
                > j=asc(ucase(mid (FilNam,i,1)))
                > if j<>45 then
                > if (j<65)+(j>90) then FilNam=left(Fil Nam,i-1)+mid(FilNam,i +1)
                > end if[/color]

                What is that supposed to be doing?
                [color=blue]
                > next
                > if FilNam2<>FilNam then
                > FilNam3="<img src="+chr$(34)+ FilNam2+chr$(34 )+"><P>"[/color]

                And again, use ampersands.
                You've got pluses throughout. Change them all to ampersands.
                [color=blue]
                > <Table bgcolor=#ffff77 ">[/color]

                Unbalanced quote. Will mess things up.
                <Table bgcolor="#ffff7 7">

                [color=blue]
                > <TR><TD align=center>
                > <form action="godlove s3.asp" name="form" method="post">[/color]

                You can just use GET for the method (passes via the URL). Save yourself the
                hassle of having to check incoming params of both get and post.
                [color=blue]
                >
                > the occurrence of <%=FilNam3%> and 4%> should, most of the time, just
                > result in a null string, but when the user puts in "JOHN WILLIAM" for
                > example, it should attempt to load both "JOHN" and "JOHNWILLIA M" .[/color]

                There will be no space in the actual URL. It will be displayed as %20. I
                believe vbscript changes it back to a space for you when you grab the param,
                but I am not certain. You'll need to test this.

                Good luck with the meeting.

                --
                --
                ~kaeli~
                He's your God, they're your rules - you burn in Hell.



                Comment

                • John

                  #23
                  Re: How can I pass an image parameter in HTML? Is it possible???

                  > VBScript/VB does not support/overload the plus operator (+) for
                  string[color=blue]
                  > concatenation. It's an ampersand. (&)[/color]

                  Actually, it appears to support it, because I'm using + on the working
                  "godloves2. asp" page.

                  <%@ LANGUAGE="VBSCR IPT" %>

                  <% Dim First, FilNam, FilNam2, i, j
                  First = trim(Request.fo rm("first"))
                  if First<"A" or First>"zza" then First="John"
                  First = ucase(left(Firs t,1))+mid(First ,2)
                  FilNam = left(First,1)+"/"+First+".g if"
                  FilNam2 = left$(First,ins tr(First+" "," ")-1)
                  for i=Len(FilNam)-4 to 3 step -1
                  j=asc(ucase(mid (FilNam,i,1)))
                  if j<>45 then if j<65 or j>90 then
                  FilNam=left(Fil Nam,i-1)+mid(FilNam,i +1)
                  next
                  if ucase(First)="C ON" then FilNam="C/Con-.gif"
                  %>

                  the above comes from www.GodLovesEveryone.org/godloves2.asp

                  I'm briefly perusing the rest of your comments before leaving for my
                  meeting. I won't be testing page "3" until later this afternoon or
                  evening.

                  John

                  Comment

                  • kaeli

                    #24
                    Re: How can I pass an image parameter in HTML? Is it possible???

                    In article <1111073799.613 387.94180@l41g2 000cwc.googlegr oups.com>,
                    GodLovesEveryon e.org@gmail.com enlightened us with...[color=blue][color=green]
                    > > VBScript/VB does not support/overload the plus operator (+) for[/color]
                    > string[color=green]
                    > > concatenation. It's an ampersand. (&)[/color]
                    >
                    > Actually, it appears to support it, because I'm using + on the working
                    > "godloves2. asp" page.[/color]

                    It won't give an error.
                    Use the ampersand. Trust me. :)

                    It was old syntax before they even added support for constants. That was
                    1996.
                    "Arithmetic Operators
                    The arithmetic operators are used with numeric variables and literals and
                    expressions. (Since VBS at the moment has no constants, they are not an issue
                    here.) The plus sign (+) can also be used as a string concatenation operator,
                    but this usage is obsolete and should be used sparingly."

                    Remember, just because you CAN do something doesn't mean you SHOULD. *heh*
                    Especially when you're using a non-strongly-typed language. Things tend to
                    get converted to another data type when you're not looking.

                    Normal VB is typed, but I'm pretty sure VBS isn't. I think everything is a
                    Variant in VBS. That can lead to issues.
                    Are you using ASP classic or ASP.NET? 'Cuz I think they changed a lot between
                    the two.

                    --
                    --
                    ~kaeli~
                    You feel stuck with your debt if you can't budge it.



                    Comment

                    Working...