SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP File Uploads Failing over 1M

    For some reason I cannot get my page to upload files larger than 1M even though all the PHP variables are set in the .ini to large settings.

    Server is Apache 2.0.52 with PHP 4.3.10 running as a CGI, not a module. There is no php.conf file.

    Anyone have ideas?

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you checked with the phpinfo() function to see that your .ini settings are actually working correctly ?
    Do the files stop working precisely around 1 mb ? for example will a 950kb file work, but a 1050 kb fail ?
    The only other thing I can think of is if your HTML form had a maxfilesize parameter, but obviously you'd know if that were the case.

  3. #3
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out the sub-sections here:

    http://us2.php.net/manual/en/features.file-upload.php

    They describe not only the php.ini setting, but those for the webserver as well.

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The phpinfo() shows the variables are correct so I don't see a problem there. As for server settings I don't see any in Appache and there is no php.conf.

    As for file sizes, everything up to a 1M file works fine, after that it won't add to the database.

  5. #5
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Won't add to the dababase or won't upload? That's two entirely different issues. What is your database field set to? Each type has it's own limits.
    Chrispian H. Burks
    Nothing To Say

  6. #6
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's set to a longblob.

  7. #7
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone have any ideas? I created some test files and it stops working right at 1024K?

  8. #8
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,629
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Have you checked the Apache config, which would supercede anything you do in PHP.

  9. #9
    SitePoint Addict Adam A Flynn's Avatar
    Join Date
    Jul 2004
    Location
    Canada
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had similar issues before. A few things to check:
    1/ Check to make sure that post_max_size, upload_max_filesize, and memory_limit are big enough for the file.
    2/ set_time_limit(0); -> Disable the time limit on the script so that it doesn't cut out before the upload's done.
    3/ Check for safe_mode, upload_tmp_dir, open_basedir, and file_uploads.
    safe_mode may or may not make PHP not like uploads [Also, check the switches PHP was compiled with. It's possible that safe_mode was compiled onto PHP, so no matter what you do to php.ini it'll still be there and make uploading potentially "icky"].
    upload_tmp_dir should be set to something, just so PHP knows it's there.
    open_basedir should be in a parent dir of upload_tmp_dir and the directory you're moving the uploaded file to. (Or be set to no value)
    file_uploads should be set to On

    You can confirm all of these values in phpinfo();

    4/ Also, apache config may mess things up too. LimitRequestBody I think is the directive that you need to watch for. If that's set too low, it will return an empty page if you try to upload a file. (Check the apache manual for more details)

    Hope that helps

  10. #10
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Update:
    This is happening on two servers. Both are XP Pro SP2 and running Apache 2.0.52.

    One is running PHP 4.3.10 as a CGI the other is running PHP 5.0.3 as a module.

    Here are the values in the PHP.INI for both servers.

    max_execution_time = 600
    max_input_time = 600
    memory_limit = 50M
    post_max_size = 51M
    upload_max_filesize = 50M
    safe_mode = Off
    upload_tmp_dir ="C:\PHP\temp"
    open_basedir is commented out

    The LimitRequestBody line is not in either servers httpd.conf file.

    I am lost here, this is two servers doing the same thing with two different versions of PHP and running as a CGI and a module.

    Please, anyone know what to do?

  11. #11
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Found It!

    Here is the solution, it's a MySQL config issue.

    http://forums.kayako.com/showthread....&threadid=1161

  12. #12
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure exactly what the application is, but normally I would not try and store large bits of information in the database. Instead, I store a reference to that file.

    For example, I had a site that showed a new image every day. Instead of storing the image in the database, I stored the path to the file. If this is a web based application where you'll be serving up this file, this is actually a more efficient way of serving up the file. If the file is stored in the database, php must first request the file, mysql has to get it, pass it back to php, then to the webserver. When you're talking about a large file, that can start requiring a lot of memory. If you simply store a reference to the file, php and mysql can fetch that very quickly and display it in the html, which allows the web server to handle the large file, which webservers are better designed to do.

    Just a suggestion.

  13. #13
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Holland
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tanks for the info. I was looking at other ways of doing it and your way sounds like it would also give me the advantage of letting the browser and the server handle it and I would get download progress bars.
    Now to get upload progress bars....hmmm.


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
  •