SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Failed to upload file exceed than 2MB

    i successfully upload files less than 2Mb. but, when try to upload file exceed than 2MB, i always get an error. i have edited some of the values in php.ini but no luck.

    post_max_size = 32M --> default is 8M

    upload_max_filesize = 50M --> default is 2M

    is there any line(s) that i need to edit?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    -call phpinfo() to determine the location of the correct php.ini file to edit.
    -edit it
    -restart webserver

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have read a tutorial from zend

    i have changed some values below

    post_max_size = 20M
    upload_max_filesize = 20M
    memory_limit = 20M

    i have restarted apached but still no luck...

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Could be server disk space quota. Some host providers (especially free) set the file size limit.
    Saul

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon
    Could be server disk space quota. Some host providers (especially free) set the file size limit.
    i am not upload my program into the actual server yet. still in my workstation. it has 256MB of memory. current memory usage (PF Usage) is 290MB.

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Did you try doing what clamcrusher suggested? Are you sure the php.ini location is correct?
    Saul

  7. #7
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon
    Did you try doing what clamcrusher suggested? Are you sure the php.ini location is correct?
    how to find it? i am still searching. i did display the phpinfo(). my php.ini file is in D:\website\php\php.ini. i made the changes on this file.

  8. #8
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If phpinfo() says it's there, then it's there. If you changed that file and restarted the web server, the changes should apply. Check if these settings are what you set in phpinfo().
    Saul

  9. #9
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did find post_max_size and upload_max_filesize. both have value 20M.

  10. #10
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What is exactly the error that you get when you try uploading it?
    Saul

  11. #11
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is my code.

    PHP Code:
    $uploadDir '../files/';
                
    $ext strrchr($fileName".");
                if(
    $ext != ".pdf" && $ext != ".PDF" && $ext != ".doc" && $ext != ".DOC"){
                    echo 
    "<br /><br /><center>Invalid file type.</center>";
                }
                else{
                    
    $filePath $uploadDir $fileName;
                    
    $result move_uploaded_file($tmpName$filePath);
                    if (!
    $result) {
                        echo 
    "<br /><br /><center>Error uploading file.</center>";
                        exit;
                    }
            
                    if(!
    get_magic_quotes_gpc())    {
                        
    $fileName addslashes($fileName);
                        
    $filePath addslashes($filePath);
                    }
                    
                    global 
    $tenderDb;
                    
    $sql "UPDATE tender SET
                            tenderNo = '
    $number', 
                            tenderTitle = '
    $title', 
                            tenderSaleDate = '
    $dateSale', 
                            tenderCloseDate = '
    $dateClose', 
                            tenderCloseTime = '
    $timeClose',
                            tenderSubmitLocation = '
    $submission',
                            tenderPrice = '
    $price', 
                            tenderCondition = '
    $condition', 
                            tenderFileName = '
    $fileName', 
                            tenderFileSize = '
    $fileSize',
                            tenderFileType = '
    $fileType', 
                            tenderFilePath = '
    $filePath', 
                            tenderStatus = '
    $status'
                            WHERE tenderId = 
    $tenderid";
                    
    $query $tenderDb->query($sql) or die(mysql_error()); 
    I always get "Error uploading file." but this error only appear if i try uploading file exceed than 2MB. if the file size is less than 2MB, then no error is displayed.

  12. #12
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Try changing move_uploaded_file() to copy() (just for debugging purposes).
    Saul

  13. #13
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon
    Try changing move_uploaded_file() to copy() (just for debugging purposes).
    same error...

  14. #14
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Are the errors turned off? Try turning them on in php.ini and see what errors does it display.
    Saul

  15. #15
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did turn on display errors and error_reporting = E_ALL

  16. #16
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Very strange. Try using is_uploaded_file additionally to check if the file was uploaded to server.
    Saul

  17. #17
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon
    Very strange. Try using is_uploaded_file additionally to check if the file was uploaded to server.
    yeah! very strange! my friend can upload 350MB file size but i wanted to set the max file size is only 20MB, but still no luck. is it because of not enough memory at this workstation (only 256MB, currently using 281MB)? i think i have to try at my notebook. mine has 512MB of memory. i'll let u know soon. thanks dude!

  18. #18
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    When it comes to uploading large files HTTP upload is very unstable the best method would be to use FTP as it was made for file transfers.

    http://www.php.net/manual/en/ref.ftp.php
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  19. #19
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in the upload script, add this at the top.
    PHP Code:
    var_dump(ini_get('upload_max_filesize'));
    var_dump(ini_get('post_max_size'));
    print_r($_FILES); 
    post the output here.

  20. #20
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    string(3) "20M" string(3) "20M" Array ( [tenderfile] => Array ( [name] => Extending_DWMX2004.pdf [type] => [tmp_name] => [error] => 2 [size] => 0 ) )

  21. #21
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do you have MAX_FILE_SIZE set in the upload form!?
    Saul

  22. #22
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon
    Do you have MAX_FILE_SIZE set in the upload form!?
    i do have it

    PHP Code:
    <input type="hidden" name="MAX_FILE_SIZE" value="20000000"
    the value above allow me to upload file which size is 20MB right? i think it works now. i dont know how i did it. i just re-installed my php. and configured several things as previous one. then, i tried it, and wow!...i can upload...this thing drive me crazy man...

  23. #23
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    [error] => 2 in $_FILES array says the file size exceeded the limit set by max_file_size. You have probably had a wrong number there.
    Saul

  24. #24
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i had increased the number before. original tutorial is 2,000,000 then i have changed it to 20,000,000. but anyhow, it works. thanks to u guys. nice help!


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
  •