Php file upload - (large file size) - (blank page, no error)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rshgeneral
    New Member
    • Feb 2010
    • 3

    Php file upload - (large file size) - (blank page, no error)

    I am having difficulty uploading some large files using php/html form. The code has worked for file sizes up to 23MB. When I've tried a 50MB file, i get a blank page instead of my confirmation echo statement. My web research indicates that I needed to alter some php directives either in an .htaccess file or php.ini. I have edited my php.ini file and included all the relevant directives I could find. Here are the newly added lines. I have confirmed the changes with a phpinfo() request. This problem was posted here but it doesn't appear as if any solution was reached.

    memory_limit = 210M
    post_max_size = 200M
    upload_max_file size = 190M
    max_input_time = 2400
    max_execution_t ime = 2400
    I don't even think max_execution_t ime is even relevant here, but it has been mentioned on several web pages.

    Relevant form code:[code=text] <form enctype="multip art/form-data" method="POST" action="uploade r.php">
    Choose a file to upload: <input name="userfile" type="file" /><br />
    <input type="submit" value="Upload File" /><br />
    </form>[/code]

    Relevant script code:[code=text]error_reporting (-1);
    if (move_uploaded_ file($_FILES['userfile']['tmp_name'], 'uploads/FreeAudio.mp3') )
    echo "File is valid, and was successfully uploaded.\n";
    else echo "Error when uploading file\n";[/code]

    What am I missing?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    Is display_errors enabled in your PHP.ini?
    I ask because if it is not, no errors will be displayed regardless of how you set error_reporting.

    The only Apache settings I know of that would cause it to reject files are the "LimitRequestBod y" directive and possibly "RLimitMem". You may want to search your .conf and .htaccess files for those.

    Comment

    • rshgeneral
      New Member
      • Feb 2010
      • 3

      #3
      Display errors is set to On. I had read about the LimitRequestBod y online, but I don't know how to check what it is currently set to. My host is GoDaddy, its a Linux shared hosting account. Can those two directives be set in the php.ini file? If so what values should I used. I don't need to post files via HTTP much any bigger than 150-200MB.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        You can't set Apache directives through PHP. At least not these. The PHP code wouldn't be executed until after the uploaded file had been rejected by Apache.

        Seeing as you are on a shared environment, I would check with the host. See if they are putting limits on the amount you can upload. - I would guess that most hosts would limit it to a few MiB, for performance reasons.

        Event though I doubt they would give you control over these sort of limits, you could try creating a .htaccess file and set them anyways.

        Comment

        • rshgeneral
          New Member
          • Feb 2010
          • 3

          #5
          Changing the tmp_upload_dir from the default, which was a the shared /tmp off of root, to a directory underneath my user directory fixed the issue. I'm not sure why this works, but it does.

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            OK, I see. That I would not have guessed.
            I have heard of uploads failing using the default temp directory (on Windows mostly), but that has always completely disabled it, not partially.

            But anyways, I'm glad you got it fixed :)

            Comment

            • mozmel
              New Member
              • May 2010
              • 1

              #7
              hi this first help from me

              go to php.ini

              and find this configration

              ; Maximum size of POST data that PHP will accept.
              post_max_size = 8M

              then change size to other like 128 or 256

              thanks
              mozmel
              from khartoum - sudan

              Comment

              • Atli
                Recognized Expert Expert
                • Nov 2006
                • 5062

                #8
                Hey mozmel.

                This issue has already been resolved a while back, as rshgeneral posted in his last entry. And the config directive you suggested was also a part of the directives mentioned in the original post, which had no effect on the problem.

                Comment

                Working...