Uploading Photos Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ralph Freshour

    Uploading Photos Help

    I'm trying to code the ability for my users to upload up to photo's to
    mysql database - can someone point me in the right direction as to how
    this might be done in php? Perhaps a tutorial or some code samples?
    My two php books don't cover uploading photo's to a web site.

    Thanks...

  • Ralph Freshour

    #2
    Re: Uploading Photos Help

    OK, I'm uisng the code below (file.php and file.html) and I'm getting
    the following error:

    Parse error: parse error, expecting `','' or `';'' in
    /home/user/public_html/file.php on line 15

    line 15 is the echo 'File Name line below - I don't understand what
    the error is and I also don't understand how the if ($File_name) var
    is working - where is this var coming from???

    file.php code:
    <?php
    if ($File_name)
    {
    if (copy($FileToUp load, "./uploads/$File_name"))
    {
    echo 'File Name :' . $File_name .';
    echo 'File Size :' . $File_size .';
    echo 'The file was successfully uploaded!';
    }
    else
    {
    echo 'Your file could not be copied.';
    }
    unlink($FileToU pload);
    }
    ?>


    HTML code:
    <form method="post" action="file.ph p">
    <input type="File" name="FileToUpl oad">
    <input type="submit" value="submit">
    <input type="reset" value="reset">
    </form>



    On Sat, 23 Aug 2003 14:44:20 GMT, Ralph Freshour <ralph@primemai l.com>
    wrote:
    [color=blue]
    >I'm trying to code the ability for my users to upload up to photo's to
    >mysql database - can someone point me in the right direction as to how
    >this might be done in php? Perhaps a tutorial or some code samples?
    >My two php books don't cover uploading photo's to a web site.
    >
    >Thanks...[/color]

    Comment

    • Matthew Vickers

      #3
      Re: Uploading Photos Help

      On Sun, 24 Aug 2003 03:02:52 GMT
      Ralph Freshour <ralph@primemai l.com> wrote:

      <snip>[color=blue]
      > Parse error: parse error, expecting `','' or `';'' in
      > /home/user/public_html/file.php on line 15[/color]

      The PHP engine can not parse your php file on line 15. It looks like it cannot tell where your statement ends because you have not closed the final string concatenation.
      [color=blue]
      > echo 'File Name :' . $File_name .';[/color]

      try: echo "File Name : $File_name";

      <snip>[color=blue]
      > I also don't understand how the if ($File_name) var
      > is working - where is this var coming from???[/color]

      You don't know ? Did you declare it ? From the code supplied the if statement will never be executed because $File_name doesn't exist.

      Clear as mud ?

      Matt

      --
      Quispiam Power Computing | "There are two major products that come out
      Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
      +61 2 9688 2894 | this to be a coincidence. "
      www.quispiam.com | - Jeremy S. Anderson

      Comment

      • Matthew Vickers

        #4
        Re: Uploading Photos Help

        On Sun, 24 Aug 2003 21:12:58 +1000
        Matthew Vickers <keep@replies.i n.ng> wrote:

        <Snip unwrapped junk>

        Sorry 'bout that. Line wrapping was not set correctly.


        Matt

        --
        Quispiam Power Computing | "There are two major products that come out
        Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
        +61 2 9688 2894 | this to be a coincidence. "
        www.quispiam.com | - Jeremy S. Anderson

        Comment

        • Ralph Freshour

          #5
          Re: Uploading Photos Help

          Thanks for the help with the image uploading - the last part I'm
          having trouble with is getting the image into a MySQL table col - I
          have the col defined as a textblob but after executing the following
          code, all I see in the table col is the filename, not the image - but
          I'm wondering now if maybe I *should* be only storing the filename in
          the table and leave the image on the server????

          $php_SQL = "UPDATE photos SET photo1 = '".$php_file."' "." WHERE
          member_name = '".$php_member_ name."'";

          Ralph

          On Sat, 23 Aug 2003 14:44:20 GMT, Ralph Freshour <ralph@primemai l.com>
          wrote:
          [color=blue]
          >I'm trying to code the ability for my users to upload up to photo's to
          >mysql database - can someone point me in the right direction as to how
          >this might be done in php? Perhaps a tutorial or some code samples?
          >My two php books don't cover uploading photo's to a web site.
          >
          >Thanks...[/color]

          Comment

          • Matthew Vickers

            #6
            Re: Uploading Photos Help

            On Sun, 24 Aug 2003 21:38:11 GMT
            Ralph Freshour <ralph@primemai l.com> wrote:
            [color=blue]
            > Thanks for the help with the image uploading - the last part I'm
            > having trouble with is getting the image into a MySQL table col - I
            > have the col defined as a textblob but after executing the following
            > code, all I see in the table col is the filename, not the image - but
            > I'm wondering now if maybe I *should* be only storing the filename in
            > the table and leave the image on the server????[/color]

            Does the variable $php_file contain the image or the image name ?
            The column type of textblob doesn't make any sense to me. Do you mean a
            blob or a text column ? The column type is academic anyway as
            either a text or blob column will do for an image AFAIK.
            [color=blue]
            > I'm wondering now if maybe I *should* be only storing the filename in
            > the table and leave the image on the server????[/color]

            This is the way I usually do it, it can be done by storing the image in
            the DB but IMHO its really not worth the extra work.


            Matt

            --
            Quispiam Power Computing | "There are two major products that come out
            Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
            +61 2 9688 2894 | this to be a coincidence. "
            www.quispiam.com | - Jeremy S. Anderson

            Comment

            • Ralph Freshour

              #7
              Re: Uploading Photos Help

              $php_file contains the filename so I guess thats why its just writing
              the filename to the table - how do I get a var to actually hold the
              image so I can write that to the table?

              I initially choose the wrong col type - I've now changed it to
              mediumblob from textblob which, as you indicated, didn't make any
              sense for an image type.

              I'd like to store the actual image in the table vs leaving it on the
              server.


              On Mon, 25 Aug 2003 07:58:52 +1000, Matthew Vickers
              <keep@replies.i n.ng> wrote:
              [color=blue]
              >On Sun, 24 Aug 2003 21:38:11 GMT
              >Ralph Freshour <ralph@primemai l.com> wrote:
              >[color=green]
              >> Thanks for the help with the image uploading - the last part I'm
              >> having trouble with is getting the image into a MySQL table col - I
              >> have the col defined as a textblob but after executing the following
              >> code, all I see in the table col is the filename, not the image - but
              >> I'm wondering now if maybe I *should* be only storing the filename in
              >> the table and leave the image on the server????[/color]
              >
              >Does the variable $php_file contain the image or the image name ?
              >The column type of textblob doesn't make any sense to me. Do you mean a
              >blob or a text column ? The column type is academic anyway as
              >either a text or blob column will do for an image AFAIK.
              >[color=green]
              >> I'm wondering now if maybe I *should* be only storing the filename in
              >> the table and leave the image on the server????[/color]
              >
              >This is the way I usually do it, it can be done by storing the image in
              >the DB but IMHO its really not worth the extra work.
              >
              >
              >Matt[/color]

              Comment

              Working...