Re basic file upload form

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

    Re basic file upload form

    I would like to create a very basic file upload add image form to add
    to my web site and to keep them in a "tmp" directory within my web
    hosting file manager once uploaded.
    I understand the basic html for the form and the basic php scripting
    but the fine details ie method post etc needs help also at this stage
    I dont want to involve mysql data base. were should I start.
  • John Dunlop

    #2
    Re: Re basic file upload form

    Simon wrote:
    [color=blue]
    > I would like to create a very basic file upload add image form to add
    > to my web site and to keep them in a "tmp" directory within my web
    > hosting file manager once uploaded.
    > I understand the basic html for the form and the basic php scripting
    > but the fine details ie method post etc needs help also at this stage
    > I dont want to involve mysql data base. were should I start.[/color]

    If you've not already done so, read



    --
    Jock

    Comment

    • Tim Van Wassenhove

      #3
      Re: Re basic file upload form

      In article <5b2fea4f.04041 61011.7d690b17@ posting.google. com>, Simon wrote:[color=blue]
      > I would like to create a very basic file upload add image form to add
      > to my web site and to keep them in a "tmp" directory within my web
      > hosting file manager once uploaded.
      > I understand the basic html for the form and the basic php scripting
      > but the fine details ie method post etc needs help also at this stage
      > I dont want to involve mysql data base. were should I start.[/color]

      Start at the source. http://www.php.net/manual

      --

      Comment

      • Simon

        #4
        Re: Re basic file upload form

        John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aea3 b91a1d753b89896 f1@News.Individ ual.NET>...[color=blue]
        > Simon wrote:
        >[color=green]
        > > I would like to create a very basic file upload add image form to add
        > > to my web site and to keep them in a "tmp" directory within my web
        > > hosting file manager once uploaded.
        > > I understand the basic html for the form and the basic php scripting
        > > but the fine details ie method post etc needs help also at this stage
        > > I dont want to involve mysql data base. were should I start.[/color]
        >
        > If you've not already done so, read
        >
        > http://www.php.net/manual/en/features.file-upload.php[/color]

        thanks for your reply .
        I have read the online manual you recommend Its all there I have to
        say the problem is I cant get any of the scripts to work Copy paste
        the scripts to my files but nothing ,I have an error log that recieves
        the errors so somthing is working parse errors on various lines but I
        cant de bug the script I am hosting with yahoo who provide all the
        configurations but no support for the actual programing. I will study
        the pages you provided . But I feel there is somthing basic missing in
        my attempts.

        Comment

        • John Dunlop

          #5
          Re: Re basic file upload form

          Simon wrote:

          [About <http://www.php.net/manual/en/features.file-upload.php>:]
          [color=blue]
          > Copy paste the scripts to my files but nothing ,I have an error log
          > that recieves the errors so somthing is working parse errors on various
          > lines but I cant de bug the script[/color]

          Whittle down a basic file upload script to a couple of lines. Then,
          if problems persist, post it here.

          --
          Jock

          Comment

          • Simon

            #6
            Re: Re basic file upload form

            John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aeb5 0bc528370c99896 f4@News.Individ ual.NET>...[color=blue]
            > Simon wrote:
            >
            > [About <http://www.php.net/manual/en/features.file-upload.php>:]
            >[color=green]
            > > Copy paste the scripts to my files but nothing ,I have an error log
            > > that recieves the errors so somthing is working parse errors on various
            > > lines but I cant de bug the script[/color]
            >
            > Whittle down a basic file upload script to a couple of lines. Then,
            > if problems persist, post it here.[/color]

            will post a basic script that I am trying to use.
            simon

            Comment

            • Simon

              #7
              Re: Re basic file upload form

              John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aeb5 0bc528370c99896 f4@News.Individ ual.NET>...[color=blue]
              > Simon wrote:
              >
              > [About <http://www.php.net/manual/en/features.file-upload.php>:]
              >[color=green]
              > > Copy paste the scripts to my files but nothing ,I have an error log
              > > that recieves the errors so somthing is working parse errors on various
              > > lines but I cant de bug the script[/color]
              >
              > Whittle down a basic file upload script to a couple of lines. Then,
              > if problems persist, post it here.[/color]

              This is the script I am trying to use for yahoo web hosting.
              The first thing is does the html and php go on the same file as a .php
              file or two seperate files.

              ------------------------------------------------------------------------
              <body>
              <form action="upload. php" method="post" ENCTYPE="multip art/form-data">
                Filename: <input type="text" size=40 name="filename" ><br>
                <input type="file" size=40 name="file"><br >
                <input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">
                <input type="submit" value="                                  Upload
                                               ">
              </form>
              <?php
              if ($file == "" || $file == "none") {
                print "You must specify a file to upload.<p><i>Yo u need a
              <b>/tmp</b> directory for uploads to work.</i><p>";
              }
              else {
                $newfile = "/php/tmp/$filename";
                echo "Uploaded as: $newfile<br>";
                //unlink($file);
              }
              ?>
              <hr>
              </body>

              Comment

              • John Dunlop

                #8
                Re: Re basic file upload form

                Simon wrote:
                [color=blue]
                > The first thing is does the html and php go on the same file as a .php
                > file or two seperate files.[/color]

                Up to you.

                [ ... ]
                [color=blue]
                >   Filename: <input type="text" size=40 name="filename" ><br>[/color]

                What's this for? You've already got:
                [color=blue]
                >   <input type="file" size=40 name="file"><br >[/color]

                which allows the user to select files.
                [color=blue]
                >   <input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">[/color]

                Mostly useless.
                [color=blue]
                >   <input type="submit" value="                                  Upload
                >                                  ">[/color]

                Browsers might ignore that leading and trailing whitespace. Got a
                good reason for including it? If not, remove it.
                [color=blue]
                > </form>
                > <?php
                > if ($file == "" || $file == "none") {[/color]

                You didn't copy 'n paste this from the Manual, did you?



                --
                Jock

                Comment

                • Simon

                  #9
                  Re: Re basic file upload form

                  John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aebc e64dc980b9d9896 f6@News.Individ ual.NET>...[color=blue]
                  > Simon wrote:
                  >[color=green]
                  > > The first thing is does the html and php go on the same file as a .php
                  > > file or two seperate files.[/color]
                  >
                  > Up to you.
                  >
                  > [ ... ]
                  >[color=green]
                  > >   Filename: <input type="text" size=40 name="filename" ><br>[/color]
                  >
                  > What's this for? You've already got:
                  >[color=green]
                  > >   <input type="file" size=40 name="file"><br >[/color]
                  >
                  > which allows the user to select files.
                  >[color=green]
                  > >   <input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">[/color]
                  >
                  > Mostly useless.
                  >[color=green]
                  > >   <input type="submit" value="                                  Upload
                  > >                                  ">[/color]
                  >
                  > Browsers might ignore that leading and trailing whitespace. Got a
                  > good reason for including it? If not, remove it.
                  >[color=green]
                  > > </form>
                  > > <?php
                  > > if ($file == "" || $file == "none") {[/color]
                  >
                  > You didn't copy 'n paste this from the Manual, did you?
                  >
                  > http://www.php.net/manual/en/features.file-upload.php[/color]


                  Hi Jock

                  im sorry about that I posted the wrong script. I hope you dont mind
                  helping with this Ill post the sript from the manual .


                  <form enctype="multip art/form-data" action="_URL_" method="post">
                  <input type="hidden" name="MAX_FILE_ SIZE" value="30000" />
                  Send this file: <input name="userfile" type="file" />
                  <input type="submit" value="Send File" />
                  </form>

                  <?php
                  // In PHP versions earlier than 4.1.0, $HTTP_POST_FILE S should be used
                  instead
                  // of $_FILES.

                  $uploaddir = '/var/www/uploads/';
                  $uploadfile = $uploaddir . $_FILES['userfile']['name'];

                  print "<pre>";
                  if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
                  {
                     print "File is valid, and was successfully uploaded. ";
                     print "Here's some more debugging info:\n";
                     print_r($_FILES );
                  } else {
                     print "Possible file upload attack!  Here's some debugging
                  info:\n";
                     print_r($_FILES );
                  }
                  print "</pre>";

                  ?>


                  This is the script and form we can work on if you dont mind
                  I have tried this however nothing appears to find its way to my tmp
                  directory. can we wittle this down to the bare script.

                  1 I have checked file uploads are allowed and enabled
                  2 php is installed on my server yahoo web hosting
                  3 the html form appears and works a file is selected from the local
                  disc.
                  4 press upload and thats it .
                  5 nothing appears in my tmp directory.

                  could you script this so it is on one php file only.

                  Regards
                  Simon

                  Comment

                  • John Dunlop

                    #10
                    Re: Re basic file upload form

                    Simon wrote:

                    [ ... ]
                    [color=blue]
                    > 1 I have checked file uploads are allowed and enabled
                    > 2 php is installed on my server yahoo web hosting
                    > 3 the html form appears and works a file is selected from the local
                    > disc.
                    > 4 press upload and thats it .
                    > 5 nothing appears in my tmp directory.[/color]

                    Stick "error_reportin g(E_ALL);" at the start of your script.

                    --
                    Jock

                    Comment

                    • Simon

                      #11
                      Re: Re basic file upload form

                      John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aed1 9312164a9699896 f9@News.Individ ual.NET>...[color=blue]
                      > Simon wrote:
                      >
                      > [ ... ]
                      >[color=green]
                      > > 1 I have checked file uploads are allowed and enabled
                      > > 2 php is installed on my server yahoo web hosting
                      > > 3 the html form appears and works a file is selected from the local
                      > > disc.
                      > > 4 press upload and thats it .
                      > > 5 nothing appears in my tmp directory.[/color]
                      >
                      > Stick "error_reportin g(E_ALL);" at the start of your script.[/color]

                      Have put on start of script.

                      log reports
                      parse error line 22


                      print "File is valid, and was successfully uploaded. ";

                      I have taken the form and script exactly as it is in the manual are
                      there details that I should change to make it work for my web hosting
                      example
                      should I add my domain and user id passwords etc somewhere.

                      regards
                      simon

                      Comment

                      • Simon

                        #12
                        Re: Re basic file upload form

                        John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aed1 9312164a9699896 f9@News.Individ ual.NET>...[color=blue]
                        > Simon wrote:
                        >
                        > [ ... ]
                        >[color=green]
                        > > 1 I have checked file uploads are allowed and enabled
                        > > 2 php is installed on my server yahoo web hosting
                        > > 3 the html form appears and works a file is selected from the local
                        > > disc.
                        > > 4 press upload and thats it .
                        > > 5 nothing appears in my tmp directory.[/color]
                        >
                        > Stick "error_reportin g(E_ALL);" at the start of your script.[/color]


                        More error reports.


                        [19-Apr-2004 09:01:34] PHP Warning: File Upload Error - No Mime
                        boundary found after start of file header in Unknown on line 0
                        [19-Apr-2004 09:01:34] PHP Parse error: parse error in /test.php on
                        line 23

                        Comment

                        • Simon

                          #13
                          Re: Re basic file upload form

                          John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aed1 9312164a9699896 f9@News.Individ ual.NET>...[color=blue]
                          > Simon wrote:
                          >
                          > [ ... ]
                          >[color=green]
                          > > 1 I have checked file uploads are allowed and enabled
                          > > 2 php is installed on my server yahoo web hosting
                          > > 3 the html form appears and works a file is selected from the local
                          > > disc.
                          > > 4 press upload and thats it .
                          > > 5 nothing appears in my tmp directory.[/color]
                          >
                          > Stick "error_reportin g(E_ALL);" at the start of your script.[/color]



                          [19-Apr-2004 09:05:59] PHP Warning: Max file size exceeded - file
                          [userfile] not saved in Unknown on line 0
                          [19-Apr-2004 09:05:59] PHP Parse error: parse error in /test.php on
                          line 23

                          Comment

                          • John Dunlop

                            #14
                            Re: Re basic file upload form

                            Simon wrote:

                            [Concerning the second example from "PHP: Handling file uploads -
                            Manual", <http://www.php.net/manual/en/features.file-upload.php>:]
                            [color=blue]
                            > parse error line 22
                            >
                            >
                            > print "File is valid, and was successfully uploaded. ";
                            >
                            > I have taken the form and script exactly as it is in the manual[/color]

                            Therein lies the problem. The fault is entirely the Manual's; its
                            inconsistent, and sometimes ignorant and clueless, style of presenting
                            examples caused this. I stress this is *not* your fault.

                            If you look closely, you'll find the first two characters of line
                            twenty-two aren't normal spaces but, probably, no-break spaces, which
                            are the cause of the parse error (at least they are in my version of
                            PHP). Viewing the source, one finds the offending line:

                            &nbsp;&nbsp; print [ ... ]

                            Two solutions: either substitute normal spaces for those no-break
                            spaces or simply remove them. Hopefully you'll straighten out the
                            other errors (actually, warnings) you enumerated in this thread.

                            --
                            Jock

                            Comment

                            • Simon

                              #15
                              Re: Re basic file upload form

                              deltacue2003@ya hoo.com (Simon) wrote in message news:<5b2fea4f. 0404190108.1a2c 56b0@posting.go ogle.com>...[color=blue]
                              > John Dunlop <usenet+2004@jo hn.dunlop.name> wrote in message news:<MPG.1aed1 9312164a9699896 f9@News.Individ ual.NET>...[color=green]
                              > > Simon wrote:
                              > >
                              > > [ ... ]
                              > >[color=darkred]
                              > > > 1 I have checked file uploads are allowed and enabled
                              > > > 2 php is installed on my server yahoo web hosting
                              > > > 3 the html form appears and works a file is selected from the local
                              > > > disc.
                              > > > 4 press upload and thats it .
                              > > > 5 nothing appears in my tmp directory.[/color]
                              > >
                              > > Stick "error_reportin g(E_ALL);" at the start of your script.[/color]
                              >
                              >
                              >
                              > [19-Apr-2004 09:05:59] PHP Warning: Max file size exceeded - file
                              > [userfile] not saved in Unknown on line 0
                              > [19-Apr-2004 09:05:59] PHP Parse error: parse error in /test.php on
                              > line 23[/color]



                              John

                              Success I have found a upload form that works although it requires
                              some work but the basics are there wich is what I am looking for. Ill
                              post it in a day or so for you to see. and maybe we can take it from
                              there.

                              many thanks for your help.
                              simon

                              Comment

                              Working...