SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard LiquidReflex's Avatar
    Join Date
    Aug 2003
    Location
    Minnesota
    Posts
    1,861
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    $_FILES['file']['size'] = "0" on one server but works fine on others?

    I'm experiencing a strange problem. I have set up an upload script where the user selects a file to upload and will check the size and compare it to the limit before uploading. For some reason, on my server it will work properly but on my client's server it returns 0 every time. I'm assuming it may be something to do with the server settings?

    I won't post the code right off the bat because it works on one server (same exact code) but not the other. PHP version on the server that DOESN'T work is 4.2.2 with safe mode off.

    Is there a server/PHP setting that I should know about that could cause this problem? It shouldn't have anything to do with the upload size as I have checked those settings, especially since the file is only 40k and the limit is 2M.

    Anyone have any ideas? Thanks.
    Kevin Hauge : Modern Leaf Design : Follow Us on Facebook
    Client Axis v.08 - client / project management script

  2. #2
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might have to do with your setting in php.ini for register_globals.

    The server that works may have register_globals turned on (allowing the superglobal variables $_FILE, $_REQUEST, $_COOKIE, etc), whereas the other server may have the setting turned off.

    It seems like it would be turned on for both servers though, as I believe that's the default setting after php 4.1.0.

    Check out the settings to see if there is a discrepancy between the values of register_globals in the two config files -- this is just a guess, could be way off.
    Ryan

  3. #3
    SitePoint Wizard LiquidReflex's Avatar
    Join Date
    Aug 2003
    Location
    Minnesota
    Posts
    1,861
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion. I checked the settings and did some tests. Before I started I had uploaded an htaccess file making sure register_globals was set on if it wasn't along with upping the upload_max_filesize.

    The local value for register_globals is set to On (because of the htaccess) while the Master is set to Off. I don't think this would be the issue as it passes the correct file name using $_FILES['file']['name']. It's just the size that is the issue.

    Using the Files tag of $_FILES['file']['error'] I discovered that it is giving me an error of 1, which means the upload is exceeding the max size set in php.ini ...

    That would be great but it actually doesn't. The file size is 40k but upload_max_filesize = 25M, post_max_size = 8M, max_execution_time = 60, file_uploads = 1. Thus I don't understand how it can be exceeding the setting ... which is why I thought maybe there was another setting I'm missing? Seems strange.
    Kevin Hauge : Modern Leaf Design : Follow Us on Facebook
    Client Axis v.08 - client / project management script

  4. #4
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe reboot the webserver that it isn't working on.

  5. #5
    SitePoint Wizard LiquidReflex's Avatar
    Join Date
    Aug 2003
    Location
    Minnesota
    Posts
    1,861
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure where the site is hosted at this moment but I'll research it and see if I can contact them about restarting. Not sure if that will resolve it, but we'll try it.
    Kevin Hauge : Modern Leaf Design : Follow Us on Facebook
    Client Axis v.08 - client / project management script

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The file uploading depends of several parameters:

    file_uploads, upload_max_filesize, upload_tmp_dir, post_max_size and max_input_time directives in php.ini

  7. #7
    SitePoint Wizard LiquidReflex's Avatar
    Join Date
    Aug 2003
    Location
    Minnesota
    Posts
    1,861
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by patter
    The file uploading depends of several parameters:
    Yes, but all of those parameters are within the right areas:

    Quote Originally Posted by LiquidReflex
    The file size is 40k but upload_max_filesize = 25M, post_max_size = 8M, max_execution_time = 60, file_uploads = 1.
    The only one different is the max_input_time which isn't in the server settings information (not sure why, it is a different version of Apache and PHP though so that's probably why it's not listed). The upload_tmp_dir is not set, but that is the same as my server.

    Just very confusing ...
    Kevin Hauge : Modern Leaf Design : Follow Us on Facebook
    Client Axis v.08 - client / project management script


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •