upload file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pratibharaut
    New Member
    • Jan 2007
    • 7

    upload file

    i'm not able to upload file from mobile J2ME to php 5.2.2, plz help me for that,
    same code is running in php4.3, but not in php5.2.2.
    I'm using $_FILES for uploading file, while using

    print_r($_FILES ), it showname,type and
    error=3 and size=0

    why this is happened?
    plz help me .
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by pratibharaut
    i'm not able to upload file from mobile J2ME to php 5.2.2, plz help me for that,
    same code is running in php4.3, but not in php5.2.2.
    I'm using $_FILES for uploading file, while using

    print_r($_FILES ), it showname,type and
    error=3 and size=0

    why this is happened?
    plz help me .
    Please post the relevant code. Use the [code] tags.

    Comment

    • aratimane
      New Member
      • May 2007
      • 3

      #3
      php.ini file setting for upload file is :

      upload_max_file size 10M
      upload_tmp_dir /var/tmp


      Here is the code :

      $uploadDir = '/home/';

      $uploadDir = $uploadDir . $_FILES['file']['name'];

      $content_length = $_SERVER['CONTENT_LENGTH '];
      echo "content_length =".$content_len gth;

      if(move_uploade d_file($_FILES['file']['tmp_name'], $uploadDir))
      {
      print "File is valid, and was successfully uploaded. ";
      print_r($_FILES );
      }

      else
      {
      print "Possible file upload attack! Here's some debugging info:\n";
      print_r($_FILES );
      }


      And Output is :

      content_length= 929
      Possible file upload attack! Here's some debugging info:
      Array
      (
      [file] => Array
      (
      [name] => walahlight_bar9 01.png:206
      [type] =>
      [tmp_name] =>
      [error] => 3
      [size] => 0
      )

      )

      it upload the file from browser but not able to upload file send from mobile(J2ME) to server. And same code is worked in php4.3.11 but not in php5.2.2. Is there any other configuration with apache2.0.59?

      plz help me to find out the answer.

      thank you!

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Originally posted by aratimane
        php.ini file setting for upload file is :

        upload_max_file size 10M
        upload_tmp_dir /var/tmp


        Here is the code :

        $uploadDir = '/home/';

        $uploadDir = $uploadDir . $_FILES['file']['name'];

        $content_length = $_SERVER['CONTENT_LENGTH '];
        echo "content_length =".$content_len gth;

        if(move_uploade d_file($_FILES['file']['tmp_name'], $uploadDir))
        {
        print "File is valid, and was successfully uploaded. ";
        print_r($_FILES );
        }

        else
        {
        print "Possible file upload attack! Here's some debugging info:\n";
        print_r($_FILES );
        }


        And Output is :

        content_length= 929
        Possible file upload attack! Here's some debugging info:
        Array
        (
        [file] => Array
        (
        [name] => walahlight_bar9 01.png:206
        [type] =>
        [tmp_name] =>
        [error] => 3
        [size] => 0
        )

        )

        it upload the file from browser but not able to upload file send from mobile(J2ME) to server. And same code is worked in php4.3.11 but not in php5.2.2. Is there any other configuration with apache2.0.59?

        plz help me to find out the answer.

        thank you!
        Check the permissions on the temp directory. It appears that the file is not getting uploaded correctly. Can you try it out on a standard web browser?

        Comment

        Working...