If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Max file size during upload, empty $_POST annoyances

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-10, 12:12
blm14 blm14 is offline
Registered User
 
Join Date: Dec 2001
Posts: 21
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:

Code:
     
<table>
<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>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<TR><TD>
<?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 />
</TD></TR><TR><TD>
<input type="submit" value="Upload File" /></TD></TR>
</form>

</table>
from php.ini:

Code:
; Maximum size of POST data that PHP will accept.
post_max_size = 15M
Halp!
Reply With Quote
  #2 (permalink)  
Old 11-16-10, 06:09
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
Reply With Quote
  #3 (permalink)  
Old 11-16-10, 07:36
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
make the file upload a separate form / page, store the post variables in a session
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On