File upload not working but no error...

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

    File upload not working but no error...

    Hello,

    I have a file upload page, and I've had it working fine, it was
    beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
    work now.

    The file name is correct, the directory where it's going on the
    server is correct (checked through prints etc.). I've changed the dir
    to 777 (is that right?) and this is what I get on the
    print_r($_FILES ); line:

    Array
    (
    [userfile] => Array
    (
    [name] => amy.txt
    [type] => text/plain
    [tmp_name] => /tmp/phpccPHUE
    [error] => 0
    [size] => 39
    )

    )

    And the file is not uploading - I'm getting an error on the line:

    if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
    {


    And yet, you'll notice the line above clearly states I get '0'
    error?!?!

    I can't work it this one out... any helpful hints? Please?

    Many many thanks,

    Amy
  • Agelmar

    #2
    Re: File upload not working but no error...

    Amy Kimber wrote:[color=blue]
    > Hello,
    >
    > I have a file upload page, and I've had it working fine, it was
    > beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
    > work now.
    >
    > The file name is correct, the directory where it's going on the
    > server is correct (checked through prints etc.). I've changed the dir
    > to 777 (is that right?) and this is what I get on the
    > print_r($_FILES ); line:
    >
    > Array
    > (
    > [userfile] => Array
    > (
    > [name] => amy.txt
    > [type] => text/plain
    > [tmp_name] => /tmp/phpccPHUE
    > [error] => 0
    > [size] => 39
    > )
    >
    > )
    >
    > And the file is not uploading - I'm getting an error on the line:
    >
    > if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))[/color]
    <snip>

    What is the value of $uploadfile?


    Comment

    • Chung Leong

      #3
      Re: File upload not working but no error...


      "Agelmar" <ifetteNOSPAM@c omcast.net> wrote in message
      news:c4v11v$2n6 ifg$1@ID-30799.news.uni-berlin.de...[color=blue]
      > Amy Kimber wrote:[color=green]
      > > Hello,
      > >
      > > I have a file upload page, and I've had it working fine, it was
      > > beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
      > > work now.
      > >
      > > The file name is correct, the directory where it's going on the
      > > server is correct (checked through prints etc.). I've changed the dir
      > > to 777 (is that right?) and this is what I get on the
      > > print_r($_FILES ); line:
      > >
      > > Array
      > > (
      > > [userfile] => Array
      > > (
      > > [name] => amy.txt
      > > [type] => text/plain
      > > [tmp_name] => /tmp/phpccPHUE
      > > [error] => 0
      > > [size] => 39
      > > )
      > >
      > > )
      > >
      > > And the file is not uploading - I'm getting an error on the line:
      > >
      > > if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))[/color]
      > <snip>
      >
      > What is the value of $uploadfile?[/color]

      And what is the error?


      Comment

      • Amy Kimber

        #4
        Re: File upload not working but no error...

        "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message news:<efqdnZEhW d1JoO7dRVn-iQ@comcast.com> ...[color=blue]
        > "Agelmar" <ifetteNOSPAM@c omcast.net> wrote in message
        > news:c4v11v$2n6 ifg$1@ID-30799.news.uni-berlin.de...[color=green]
        > > Amy Kimber wrote:[color=darkred]
        > > > Hello,
        > > >
        > > > I have a file upload page, and I've had it working fine, it was
        > > > beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
        > > > work now.
        > > >
        > > > The file name is correct, the directory where it's going on the
        > > > server is correct (checked through prints etc.). I've changed the dir
        > > > to 777 (is that right?) and this is what I get on the
        > > > print_r($_FILES ); line:
        > > >
        > > > Array
        > > > (
        > > > [userfile] => Array
        > > > (
        > > > [name] => index.html
        > > > [type] => text/plain
        > > > [tmp_name] => /tmp/phpccPHUE
        > > > [error] => 0
        > > > [size] => 39
        > > > )
        > > >
        > > > )
        > > >
        > > > And the file is not uploading - I'm getting an error on the line:
        > > >
        > > > if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))[/color]
        > > <snip>
        > >
        > > What is the value of $uploadfile?[/color][/color]


        $uploadfile = $uploaddir . $_FILES['userfile']['name'];

        which comes out as...

        /web/demo/translation/index.html

        which seems correct,
        [color=blue]
        > And what is the error?[/color]

        that's just hte point, [error] => 0 - but the line that's throwing the
        error is:

        if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
        {

        I have had this code working before on another server, so what am I
        doing wrong? Please! Any comments at all would be useful!

        :-)

        Many thanks,

        Amy


        here's the whole code

        ---------------------

        <?php

        session_start() ;

        ?>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

        <html xmlns="http://www.w3.org/1999/xhtml">

        <head>

        <title>File upload</title>

        <meta http-equiv="Content-Type" content="text/html;
        charset=iso-8859-1" />

        </head>



        <?php

        // In PHP versions earlier than 4.1.0, $HTTP_POST_FILE S should be used
        instead

        // of $_FILES. In PHP versions earlier than 4.0.3, use copy() and

        // is_uploaded_fil e() instead of move_uploaded_f ile.


        $uploaddir = '/web/demo/translation/';

        $uploadfile = $uploaddir . $_FILES['userfile']['name'];

        print ($uploadfile);
        print ($_FILES['userfile']['name']);
        print "<pre>";
        print_r($_FILES );
        print ("name: " . $uploadfile);

        if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
        {

        $msg = "File (" . $_FILES['userfile']['name'] . ") is valid, and
        was successfully uploaded. ";

        //print_r($_FILES );
        $jobid = time();
        $rename = $jobid . $_FILES['userfile']['name']; //or $rename =
        $username;
        $file_name = $_FILES['userfile']['name'];
        $read_extension = explode(".", $file_name);
        $ext = $read_extension[1];
        //$rename = $rename.".".$ex t;
        rename($file_na me, $rename);
        $info = array($rename, $_FILES['userfile']['type']);
        session_registe r('info');
        session_start() ;
        } else {
        $msg = "File did not upload successfully, close window and try
        againn";
        $msg = $msg . print_r($_FILES );
        }

        ?>

        <BODY bgColor=#ffffff >
        etc. etc.

        ----------------------

        and the output is this:

        ------------

        /web/demo/translation/index.html
        index.html
        Array
        (
        [userfile] => Array
        (
        [name] => index.html
        [type] => text/html
        [tmp_name] => /tmp/phpEyvvil
        [error] => 0
        [size] => 477
        )

        )
        name: /web/demo/translation/index.html

        Array
        (
        [userfile] => Array
        (
        [name] => index.html
        [type] => text/html
        [tmp_name] => /tmp/phpEyvvil
        [error] => 0
        [size] => 477
        )

        )


        Upload File File did not upload successfully, close window and try
        againn1

        Comment

        Working...