chpicker
Programmer
- Apr 10, 2001
- 1,316
I have a very simple PHP script. Here is its current code:
This code works perfectly for the most part. If I submit a simple text file, the text file appears in the browser with line numbers. If I try to submit a binary file, it looks funny, but it still works. If I try to submit a file that is a little larger than 30k, I get error code 2. I have upload_max_filesize = 20M in php.ini.
If I try to upload a 13M text file, it doesn't work. In fact, the first IF statement returns false and I just get the form back again. The browser is sending a POST (if I hit F5, it asks me to confirm that I want to re-send the data), but NONE of my form variables are being submitted. The script just acts like no post happened at all.
FYI, my intent is to attempt to upload text files as large as 50M and import them into a database. Originally I had the MAX_FILE_SIZE set to 20000000 to match the 20M in the php.ini file so I could upload the 13MB text file.
I can't debug this when I'm getting no errors whatsoever...it just pretends like I didn't even submit anything!
Any suggestions? I'm running php 5.2.6 on IIS 7.0 under Windows Vista. (Yes, I know. Shut up. I fought with this thing for 4 hours last night just to get PHP working at all!)
Code:
<?php
if (isset($_POST["Submit"])) {
if ($_FILES["inputfile"]["error"]==0) {
echo "<PRE>";
$fp=fopen($_FILES["inputfile"]["tmp_name"],"r");
$line=0;
while (!feof($fp)) {
$buffer=fgets($fp);
echo str_pad($line++,6,"0",STR_PAD_LEFT) . ": " . $buffer;
}
echo "</PRE>";
} else {
echo $_FILES["inputfile"]["tmp_name"] . " is not an uploaded file.<BR>\n";
echo "Original file name: " . $_FILES["inputfile"]["name"] . "<BR>\n";
echo "Type: " . $_FILES["inputfile"]["type"] . "<BR>\n";
echo "Size: " . $_FILES["inputfile"]["size"] . "<BR>\n";
echo "Error: " . $_FILES["inputfile"]["error"] . "<BR>\n";
}
exit();
}
?>
<form enctype="multipart/form-data" action='import.php' method='post'>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type='file' name='inputfile'>
<input type='submit' name='Submit' value='Submit'>
</form>
This code works perfectly for the most part. If I submit a simple text file, the text file appears in the browser with line numbers. If I try to submit a binary file, it looks funny, but it still works. If I try to submit a file that is a little larger than 30k, I get error code 2. I have upload_max_filesize = 20M in php.ini.
If I try to upload a 13M text file, it doesn't work. In fact, the first IF statement returns false and I just get the form back again. The browser is sending a POST (if I hit F5, it asks me to confirm that I want to re-send the data), but NONE of my form variables are being submitted. The script just acts like no post happened at all.
FYI, my intent is to attempt to upload text files as large as 50M and import them into a database. Originally I had the MAX_FILE_SIZE set to 20000000 to match the 20M in the php.ini file so I could upload the 13MB text file.
I can't debug this when I'm getting no errors whatsoever...it just pretends like I didn't even submit anything!
Any suggestions? I'm running php 5.2.6 on IIS 7.0 under Windows Vista. (Yes, I know. Shut up. I fought with this thing for 4 hours last night just to get PHP working at all!)