I have a very standard upload script that I want to use to upload a file. I wrote in on one server, where it worked fine, but when I moved it to another server it started acting flakey.
The flakeyness occurs when the file is larger than about 120KB.
When the file is uploaded via the browser it's first written to an array called $HTTP_POST_FILES as $HTTP_POST_FILES["img1"]["tmp_name"]. After the file is uploaded I use a copy command to copy the file from $HTTP_POST_FILES["img1"]["tmp_name"] to
it's permanent location. When the file that I'm attempting to upload is larger than ~120KB nothing is being written to $HTTP_POST_FILES["input_form_name"]["tmp_name"] so the copy command is obviously failing. If the file is less than ~120KB there is no problem, the script runs as it should.
The server admin tells me that their upload limit is set at 20MB. I've included the code below. If someone could help me, I'd really appreciate it. I've no clue.
<form enctype="multipart/form-data" method="post" action="do_upload.php">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="2000000">
<p><strong>File to Upload:</strong><br>
<input type="file" name="img1" size="30"></p>
<P><input type="submit" name="submit" value="Upload File"></p>
<input type="hidden" name="date" value="<?php echo $date?>">
<input type="hidden" name="storyid" value="<?php echo $storyid?>">
</form>
//file do_upload.php below
set_time_limit (0);
if ($HTTP_POST_FILES["img1"]["name"]!= "") {
echo 'image name<br>';
print_r($HTTP_POST_FILES["img1"]["name"]);
echo '<br>temp image name<br>';
print_r($HTTP_POST_FILES["img1"]["tmp_name"]);
copy($HTTP_POST_FILES["img1"]["tmp_name"], "/home/gca/www/test/news/images/".$HTTP_POST_FILES["img1"]["name"])
or die("Couldn't copy the file!");
} else {
// if $_FILES['img1'] was empty, die and let us know why
die("No input file specified");
}
Thanks ever so much
B