File Upload works but only for empty file

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

    File Upload works but only for empty file

    Good Day,

    I can upload a file as long as it is empty (thanks Hendri Kurniawan).
    I do not know where to look.

    Can someone help me understand what I need to do to upload a small image.


    Here is some more info http://chops.novatrope.com/info.php

    Thanks,
    Arthur Jacobs

  • Andy Hassall

    #2
    Re: File Upload works but only for empty file

    On Tue, 16 Jan 2007 14:10:10 -0800, Arthur Jacobs <star@sonic.net wrote:
    >I can upload a file as long as it is empty (thanks Hendri Kurniawan).
    >I do not know where to look.
    >
    >Can someone help me understand what I need to do to upload a small image.
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • Rik

      #3
      Re: File Upload works but only for empty file

      Arthur Jacobs wrote:
      Good Day,
      >
      I can upload a file as long as it is empty (thanks Hendri Kurniawan).
      I do not know where to look.
      >
      Can someone help me understand what I need to do to upload a small
      image. http://chops.novatrope.com/game/test/upload_file3.php
      >
      Here is some more info http://chops.novatrope.com/info.php
      Perhaps:
      upload_tmp_dir no value

      It should take the systems default if nothing is set, but maybe there's
      something wrong with it. Try to make a tmp dir, chmod 0766, set it as
      upload_tmp_dir, and try again. If that doesn't work, maybe try 0777.

      The rest of the values all seem OK.
      --
      Rik Wasmus


      Comment

      • Rik

        #4
        Re: File Upload works but only for empty file

        Rik wrote:
        Arthur Jacobs wrote:
        >Good Day,
        >>
        >I can upload a file as long as it is empty (thanks Hendri
        >Kurniawan). I do not know where to look.
        >>
        >Can someone help me understand what I need to do to upload a small
        >image. http://chops.novatrope.com/game/test/upload_file3.php
        >>
        >Here is some more info http://chops.novatrope.com/info.php
        >
        Perhaps:
        upload_tmp_dir no value
        >
        It should take the systems default if nothing is set, but maybe
        there's something wrong with it. Try to make a tmp dir, chmod 0766,
        set it as upload_tmp_dir, and try again. If that doesn't work, maybe
        try 0777.
        >
        The rest of the values all seem OK.
        If I construct a form to post I get a:

        UPLOAD_ERR_PART IAL
        Value: 3; The uploaded file was only partially uploaded.

        So it indeed seems a write issue on the server side.

        Oh, and if that doesn't work, please share the code with us. I can browse
        http://chops.novatrope.com/game/test/, but I cannot see the code :-).
        --
        Rik Wasmus


        Comment

        • Arthur Jacobs

          #5
          Re: File Upload works but only for empty file

          Thanks Rik,
          I will tell you what I did but it does not seemed to have helped. I added
          upload_tmp_dir = "/usr/tmp";
          to my php.ini file
          Then I restarted apache and tried to upload
          and when I try to upload I get the infamous: Error: 3

          Any more ideas I am all ears and eyes!

          Thanks,
          Arthur

          On 2007-01-16 14:28:43 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
          Arthur Jacobs wrote:
          >Good Day,
          >>
          >I can upload a file as long as it is empty (thanks Hendri Kurniawan).
          >I do not know where to look.
          >>
          >Can someone help me understand what I need to do to upload a small
          >image. http://chops.novatrope.com/game/test/upload_file3.php
          >>
          >Here is some more info http://chops.novatrope.com/info.php
          >
          Perhaps:
          upload_tmp_dir no value
          >
          It should take the systems default if nothing is set, but maybe there's
          something wrong with it. Try to make a tmp dir, chmod 0766, set it as
          upload_tmp_dir, and try again. If that doesn't work, maybe try 0777.
          >
          The rest of the values all seem OK.

          Comment

          • Rik

            #6
            Re: File Upload works but only for empty file

            Arthur Jacobs wrote:
            Thanks Rik,
            I will tell you what I did but it does not seemed to have helped. I
            added upload_tmp_dir = "/usr/tmp";
            to my php.ini file
            Then I restarted apache and tried to upload
            and when I try to upload I get the infamous: Error: 3
            >
            Any more ideas I am all ears and eyes!
            Does /usr/tmp exists?
            Is /usr/tmp writable? What permissions do you have exactly?
            Does the 'empty' file get uploaded to that location now?

            And why does you php_info() still say "upload_tmp _dir no value no value"?
            Have you edited /usr/local/etc/php.ini or another .ini file?

            If that's all OK, what happens if you try to make a file with php itself in
            /usr/tmp? Any errors?

            And last but not least: what's the code you use?
            --
            Rik Wasmus


            Comment

            • Arthur Jacobs

              #7
              Re: File Upload works but only for empty file

              On 2007-01-16 16:09:28 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
              Does /usr/tmp exists?
              I think so it showed up in my ftp program.
              Is /usr/tmp writable? What permissions do you have exactly?
              yes 0777
              Does the 'empty' file get uploaded to that location now?
              Yup, I just tested it. It returns:
              Upload: empty.html
              Type: text/html
              Size: 0 Kb
              Stored in: /var/tmp/phpBKG7BF
              >
              And why does you php_info() still say "upload_tmp _dir no value no value"?
              This is a good question. I am new to php so I am not sure.
              Have you edited /usr/local/etc/php.ini or another .ini file?
              usr/local/etc/php.ini
              /////////////////////////////////////////////////////////////////
              I see now the permissions did not change, sorry, let me try again and I
              will get back to you pronto:
              /////////////////////////////////////////////////////////////
              >
              If that's all OK, what happens if you try to make a file with php itself in
              /usr/tmp? Any errors?
              >
              And last but not least: what's the code you use?
              <?php
              // In PHP versions earlier than 4.1.0, $HTTP_POST_FILE S should be used instead
              // of $_FILES.

              $uploaddir = '/usr/home/arthur/public_html/game/test/uploads/';
              $uploadfile = $uploaddir . basename($_FILE S['userfile']['name']);

              echo '<pre>';
              if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile)) {
              echo "File is valid, and was successfully uploaded.\n";
              } else {
              echo "Possible file upload attack!\n";
              }

              echo 'Here is some more debugging info:';
              print_r($_FILES );

              print "</pre>";

              ?>

              Comment

              • Rik

                #8
                Re: File Upload works but only for empty file

                Arthur Jacobs wrote:
                On 2007-01-16 16:09:28 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
                >Does /usr/tmp exists?
                I think so it showed up in my ftp program.
                >Is /usr/tmp writable? What permissions do you have exactly?
                yes 0777
                >Does the 'empty' file get uploaded to that location now?
                Yup, I just tested it. It returns:
                Upload: empty.html
                Type: text/html
                Size: 0 Kb
                Stored in: /var/tmp/phpBKG7BF
                /var/tmp is _not_ /usr/tmp
                --
                Rik Wasmus


                Comment

                • Arthur Jacobs

                  #9
                  Re: File Upload works but only for empty file

                  On 2007-01-16 16:47:54 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
                  Arthur Jacobs wrote:
                  >On 2007-01-16 16:09:28 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
                  >>Does /usr/tmp exists?
                  >I think so it showed up in my ftp program.
                  >>Is /usr/tmp writable? What permissions do you have exactly?
                  >yes 0777
                  >>Does the 'empty' file get uploaded to that location now?
                  >Yup, I just tested it. It returns:
                  >Upload: empty.html
                  >Type: text/html
                  >Size: 0 Kb
                  >Stored in: /var/tmp/phpBKG7BF
                  >
                  /var/tmp is _not_ /usr/tmp
                  Sorry this is beyond me a little. I know var/tmp is not usr/tmp, but I
                  thought that "Stored in" may have been the temporary place where the
                  computer made the temporary file.

                  I have a tmp folder in root that has a file created today. I think
                  that is where the uploads are going but I am not sure.

                  Sorry I wish I was more help but all your help is appreciated!

                  Thanks,
                  arthur

                  Comment

                  • Arthur Jacobs

                    #10
                    Resolved Re: File Upload works but only for empty file

                    Happy days are here again....
                    Good Day,

                    In case you run into this problem again have the person make sure their
                    var/log dir is not full. Mine was overflowing, and that was the whole
                    problem (my fault-no excuse). I want to thank you guys and gals for
                    your patience and help!

                    serene at last,
                    ~arthur


                    We were getting close to the problem it had to do with the log files on
                    the server. On 2007-01-16 17:38:21 -0800, Arthur Jacobs
                    <star@sonic.net said:
                    On 2007-01-16 16:47:54 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
                    >
                    >Arthur Jacobs wrote:
                    >>On 2007-01-16 16:09:28 -0800, "Rik" <luiheidsgoeroe @hotmail.comsai d:
                    >>>Does /usr/tmp exists?
                    >>I think so it showed up in my ftp program.
                    >>>Is /usr/tmp writable? What permissions do you have exactly?
                    >>yes 0777
                    >>>Does the 'empty' file get uploaded to that location now?
                    >>Yup, I just tested it. It returns:
                    >>Upload: empty.html
                    >>Type: text/html
                    >>Size: 0 Kb
                    >>Stored in: /var/tmp/phpBKG7BF
                    >>
                    >/var/tmp is _not_ /usr/tmp
                    >
                    Sorry this is beyond me a little. I know var/tmp is not usr/tmp, but I
                    thought that "Stored in" may have been the temporary place where the
                    computer made the temporary file.
                    >
                    I have a tmp folder in root that has a file created today. I think
                    that is where the uploads are going but I am not sure.
                    >
                    Sorry I wish I was more help but all your help is appreciated!
                    >
                    Thanks,
                    arthur

                    Comment

                    Working...