Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2001

    Unanswered: Max file size during upload, empty $_POST annoyances

    I am creating a PHP upload form for the first time. I realize that if the file exceeds the max file size specified in php.ini that I will lose ALL my $_POST variables, which I don't like, but I am resigned to it. What I want to do is DETECT when this has happened, present an error to the user, and force them to go back to a page where the workflow can kind of start again and my $_POST variables will be retained.

    How can I detect when the file they're attempting to upload is too big? Or, even better, can I use javascript to cancel the form submission if the file is too big!?

    here's my form:

    <form action="JCAHO.php" method="post">
    <TR><TD><input type="submit" value="Cancel file upload and go back"></TD></TR>
    <?php print('<input type="hidden" name="user_id" value="'.$_POST['user_id'].'">');?>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    <?php print('<input type="hidden" name="user_id" value="'.$_POST['user_id'].'">');?>
    <input type="hidden" name="action" value="upload">
    <?php print('<input type="hidden" name="file_desc" value="'.$_POST['file_desc'].'">');?>
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" /></TD></TR>
    from php.ini:

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

  2. #2
    Join Date
    Feb 2002
    San Francisco, CA

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    make the file upload a separate form / page, store the post variables in a session
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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