www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Upload File Size > config something size

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Location
    /ramdisk/
    Posts
    865

    resolved [RESOLVED] Upload File Size > config something size

    The situation:
    I have a client who lives far away from me. He's wanting to send me videos. I don't want to confuse him with an upload host.



    The problem:
    The files are too big, some are 100MB. Here's the error:

    Notice: Undefined index: uploadedfile in /home/content/v/i/r/vir/html/upload/index.php on line 21

    Notice: Undefined index: uploadedfile in /home/content/v/i/r/vir/html/upload/index.php on line 35

    The page does work when you upload an image (~1-3MB). So I'm fairly sure it's the file's size causing this problem. It breaks with an 11MB file and above.


    The code I'm using (index.php):
    PHP Code:
    <?php
    ini_set
    ("upload_max_filesize""204857600");
    ini_set("post_max_size""204857600");
    ini_set("max_execution_time""1200");
    set_time_limit(1200);
    error_reporting(E_ALL);
    ?>


    <form enctype="multipart/form-data" action="index.php?set=upload&do=up" method="post">
        <input type="hidden" name="MAX_FILE_SIZE" value="204857600" />
        Choose a file to upload: <input name="uploadedfile" type="file" /><br />
        </td></tr><tr><td align="center">
        <br />
        <input type="submit" value="Upload File" />
        </form>

    <?php 

    if ($_GET['do'] == 'up') {
    $target_name basename$_FILES['uploadedfile']['name']);
    $target_path "";

    $ext =     end(explode(".",$target_name));

    if (
    $ext == "php") die('php... lol');

    $target_path "" $target_path "" $target_name ""
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);

    echo 
    $target_path " was successfully uploaded.";
    }

    echo 
    "<br /><br /><br />Here is a list of the files uploaded:<br />";
    if (
    $handle opendir('/home/content/v/i/r/vir/html/upload/')) {
        echo 
    "Files:<br />";

    $files = array();

        
    /* This is the correct way to loop over the directory. */
        
    while (false !== ($file readdir($handle))) {
                  if (
    $file == ".") continue;
                  if (
    $file == "..") continue;
                  if (
    $file == "index.php") continue;
                  
    substr_count($file,".") ? $file $file $file .= "/";
                  
    $files[$file] = $file;
        }

    sort($filesSORT_LOCALE_STRING);

    foreach (
    $files as $f) {
        echo  
    "<a href=\"$f\">$f</a><br />"
    }
       
    closedir($handle);    
    }

    ?>
    Last edited by eval(BadCode); 12-18-2010 at 11:57 PM.

  2. #2
    Join Date
    Dec 2010
    Location
    Knoxville, Tn
    Posts
    22
    File upload limitations are also set in the php.ini file. Use PHPInfo to check it. I don't remember the exact name of the setting but I think it's something obvious (line max_upload_size or something).

    This is the master setting, so it can't overridden inline in your PHP. If this is the issue, changing this setting depends on your host. Godaddy probably will not allow you to access a php.ini file (unless you have a dedicated server with them). Another way would be .htaccess, but I'm not sure if Godaddy allows that either.

    You might find this setting somewhere in your Godady control panel.

  3. #3
    Join Date
    Jul 2010
    Location
    /ramdisk/
    Posts
    865
    Too hard to figure out. I can find their php.ini w/

    Code:
    >grep 'php.ini' * -rlH 
    >php -i | grep 'Configuration File'
    but, can't alter it (the wonders of shared hosting). I tried copying it to ~ and editing. No luck. Gave up, called support- the lady solved the problem in like 30 seconds lol. The file needs to be in the webroot ~html/

    My only gripe(s)....

    Code:
    >apropos text 
    text: nothing appropriate
    >nano 
    -bash: nano: command not found
    >pico
    -bash: pico: command not found
    >apropos apropos
    apropos: nothing appropriate
    >cat > php.ini && echo "get some text editors"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles