PHP file upload problem

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

    PHP file upload problem

    Hi all,

    Heres a strange problem i am running into running Php4.2.2. I am
    uploading a file using a post and when i receive the file on my share
    the file adds some more records to it ( These are duplicate records
    in the file). Dont know whats happening all input is appreciated.

    Heres the code:
    main.php
    <?
    ....
    echo "<FORM ENCTYPE='multip art/form-data' ACTION='abc.php '
    METHOD=POST>";
    echo "<INPUT TYPE=hidden name=MAX_FILE_S IZE value=1000000>" ;
    echo "<INPUT NAME=userfile TYPE=file>";
    echo "<INPUT TYPE=submit VALUE='Continue '>";
    echo "</FORM>";
    ....
    ?>

    abc.php

    <?
    ....

    $file = $HTTP_POST_FILE S['userfile']['name'];

    // this shows more than actual size;

    echo $HTTP_POST_FILE S['userfile']['size'];
    if (is_uploaded_fi le($userfile)) {
    copy($userfile, "/tmp/$file");

    .... }

    ?>

    Please advise.

    Thanks
    S
  • Shawn Wilson

    #2
    Re: PHP file upload problem

    phantom wrote:
    [color=blue]
    > Heres a strange problem i am running into running Php4.2.2. I am
    > uploading a file using a post and when i receive the file on my share
    > the file adds some more records to it ( These are duplicate records
    > in the file). Dont know whats happening all input is appreciated.
    >
    > Heres the code:
    > main.php
    > <?
    > ...
    > echo "<FORM ENCTYPE='multip art/form-data' ACTION='abc.php '
    > METHOD=POST>";
    > echo "<INPUT TYPE=hidden name=MAX_FILE_S IZE value=1000000>" ;
    > echo "<INPUT NAME=userfile TYPE=file>";
    > echo "<INPUT TYPE=submit VALUE='Continue '>";
    > echo "</FORM>";
    > ...
    > ?>
    >
    > abc.php
    >
    > <?
    > ...
    >
    > $file = $HTTP_POST_FILE S['userfile']['name'];
    >
    > // this shows more than actual size;
    >
    > echo $HTTP_POST_FILE S['userfile']['size'];
    > if (is_uploaded_fi le($userfile)) {
    > copy($userfile, "/tmp/$file");
    >
    > .... }
    >
    > ?>[/color]

    Could you give us a sample of the files you're trying ( a before version and an
    after version )?
    You're sure that the new file is replacing the old one in /tmp (in other words,
    you're sure that there's no error when the $userfile is being copied over
    /tmp/$file)? If not, check the time.
    Why did you code the last 2 lines like this:
    [color=blue]
    > if (is_uploaded_fi le($userfile)) {
    > copy($userfile, "/tmp/$file");[/color]

    instead of using $HTTP_POST_FILE S?

    --
    Shawn Wilson
    shawn@glassgian t.com

    Comment

    • phantom

      #3
      Re: PHP file upload problem

      >[color=blue]
      > Could you give us a sample of the files you're trying ( a before version and an
      > after version )?
      > You're sure that the new file is replacing the old one in /tmp (in other words,
      > you're sure that there's no error when the $userfile is being copied over
      > /tmp/$file)? If not, check the time.
      > Why did you code the last 2 lines like this:
      >[color=green]
      > > if (is_uploaded_fi le($userfile)) {
      > > copy($userfile, "/tmp/$file");[/color]
      >
      > instead of using $HTTP_POST_FILE S?[/color]


      Before i mention about the files there is something strange i ran
      into. On changing the files extension to abc.php3 from abc.php it
      uploaded the files in the tmp directory correctly. The 3 extension is
      for php version 3 i am guessing which was originally residing on the
      server (we moved to php 4 lately a little bizarre) . Yeah so the point
      is that the php3 extensions work fine whereas php itself does not. I
      ran a php info() on the files labelled as php3 and as php but could
      not find much differences. For one thing I am sure the problem lies
      with the php-module its picking up... Shoould I be looking at
      something else too. Please let me know

      Now to answer about the files before and after.
      Before its a simple txt file

      James Douglas Buffalo NY
      Rick Yale JacksonVille FL
      .....

      the records get messed up in no known format and so happens

      as
      James Douglas Buffalo NY
      Rick Yale JacksonVille FL
      .....

      J Douglas Buffalo NY
      Rick Yale JacksonVille FL

      It is to note that the repetitive record drops some charactes as the
      James turned J.

      Thanks much
      S

      Comment

      Working...