Results 1 to 8 of 8
  1. #1

    PHP: Large file uploads

    Hey all,
    I've been trying to allow my PHP to handle large file uploads and I can't seem to make it work. The thing is I want the larger limit to be only on one file (admin.php) because for other uploads made by normal users the default size limit is ok.
    I've added php_value directives to my apache configuration inside a <LocationMatch> tag and it didn't work, so I added those lines to my admin.php :
    Code:
    @ini_set( 'upload_max_size' , '15M' );
    @ini_set( 'post_max_size', '16M');
    @ini_set( 'max_execution_time', '300' );
    It still doesn't work. I don't receive any error message so it's really hard to figure out what's wrong with what I am doing. Uploading files under 2MB works fine and over that, it won't work. I'm on a dedicated server too so I should be able to override those settings easily.. Anybody can help me? Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Bangalore
    Posts
    41
    Change the setting using php.ini file.

    All the configuration settings for your php installation are contained in the php.ini file.

    You can call the phpinfo() function to find the location of your php.ini file, it will also tell you the current values.
    Serversignature.com - Professional Linux Consulting.

  3. #3
    Join Date
    Aug 2001
    Location
    Orange County, CA
    Posts
    532
    If you prefix ini_set() with '@' then you'll suppress any errors and not see them anyway.

    If your PHP is running with safe_mode=On then you won't be able to overload the php.ini using ini_set().

    As mentioned above, your best bet is to increase the values in the php.ini file and then restart Apache.
    Jeff Standen, Chief of R&D, WebGroup Media LLC. - LinkedIn
    Cerb is a fast and flexible web-based platform for business collaboration and automation. http://www.cerbweb.com/

  4. #4
    Join Date
    Aug 2001
    Location
    Boston
    Posts
    1,569
    Quote Originally Posted by Khao8 View Post
    Hey all,
    I've been trying to allow my PHP to handle large file uploads and I can't seem to make it work. The thing is I want the larger limit to be only on one file (admin.php) because for other uploads made by normal users the default size limit is ok.
    I've added php_value directives to my apache configuration inside a <LocationMatch> tag and it didn't work, so I added those lines to my admin.php :
    Code:
    @ini_set( 'upload_max_size' , '15M' );
    @ini_set( 'post_max_size', '16M');
    @ini_set( 'max_execution_time', '300' );
    It still doesn't work. I don't receive any error message so it's really hard to figure out what's wrong with what I am doing. Uploading files under 2MB works fine and over that, it won't work. I'm on a dedicated server too so I should be able to override those settings easily.. Anybody can help me? Thanks
    You might not be able to override those settings directly at runtime. The best bet is to modify those settings in your php.ini (and don't forget to restart your web server!)
    InterNich LLC
    Founder

    Bringing you PicResize.com (More than 95 million pictures resized since 2005)

  5. #5
    Join Date
    Mar 2005
    Location
    Athens, Greece
    Posts
    1,528
    The 2 first settings must be changed server wide or per directory from your host - you cannot override these settings in your account with an .htaccess, php.ini or ini_set.
    Antonis Adamakos @ FuzzFree :: Fully Managed Web Hosting, Development, Online Marketing

  6. #6
    Join Date
    Jan 2008
    Posts
    84
    for large file uploads use the ftp class in php. Otherwise it will never work properly.

  7. #7
    Join Date
    Apr 2009
    Location
    USA / UK
    Posts
    4,553
    Quote Originally Posted by Khao8 View Post
    Hey all,<<snip>>
    Code:
    @ini_set( 'upload_max_size' , '15M' );
    @ini_set( 'post_max_size', '16M');
    @ini_set( 'max_execution_time', '300' );
    I don't receive any error message <<snip>>
    You won't get any errors with @ prepended since having @ prepended is like setting error_reporting(0); for that function call.

    Remove the @ from the function call and the errors should appear.
    RAM Host -- Premium & Budget Linux Hosting From The USA & EU
    █ Featuring Powerful cPanel CloudLinux Shared Hosting
    █ & Cheap Premium Virtual Dedicated Servers
    Follow us on Twitter

  8. #8
    Quote Originally Posted by 01globalnet View Post
    The 2 first settings must be changed server wide or per directory from your host - you cannot override these settings in your account with an .htaccess, php.ini or ini_set.
    You can override upload_max_size and post_max_size via htaccess.

    The reason why it probably isn't working is because the file upload happens before the script is called. Set it outside the script (htaccess or php.ini), and it should work fine.

Similar Threads

  1. Replies: 2
    Last Post: 04-13-2009, 12:43 PM
  2. Large files uploads PHP/Perl
    By Joel Smit in forum Dedicated Server
    Replies: 6
    Last Post: 07-21-2007, 01:18 PM
  3. Replies: 5
    Last Post: 02-25-2005, 04:13 PM
  4. Large Uploads Suggestions
    By camt in forum Programming Discussion
    Replies: 2
    Last Post: 04-25-2003, 03:36 PM

Posting Permissions

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