When I use the same code to upload a small file, it works fine. But when I select a big file (19 MB *.wmv video), the upload fails. There are no warnings or errors shown, even though I have the "or die" statement on the move_uploaded_file() and mysql_query() function calls.
I tried increasing the "<input type="hidden" name="MAX_FILE_SIZE" value="2000000">" to 2000000000, but it didn't do anything.
Why is it not working with a 19 MB file, when it works fine with a small file?
I tried increasing the "<input type="hidden" name="MAX_FILE_SIZE" value="2000000">" to 2000000000, but it didn't do anything.
Why is it not working with a 19 MB file, when it works fine with a small file?
Code:
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td>First name: <input name="fname" type="text"><br></td>
<td>Last name: <input name="lname" type="text"><br></td>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
<?php
// Insert form values (fname, lname, userfile info)
$uploadDir = "C:\\xampp\\xampp\htdocs\upload\\";
if (isset($_POST['upload'])
&& !empty($_POST['fname'])
&& !empty($_POST['lname'])
&& !empty($_FILES['userfile']['name']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath) or die ('File upload failed: ' . mysql_error()) ;
if (!$result)
{
echo "Error uploading file";
exit;
}
include 'config.php';
include 'opendb.php';
if (!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO med_test (fname, lname, fileName, size, type, link, time)
VALUES ('$fname', '$lname', '$fileName', '$fileSize', '$fileType', '$filePath', NOW())";
mysql_query($query) or die ('insert query failed: ' . mysql_error());
include 'closedb.php';
echo "<br> Files uploaded<br>";
}
else { echo "Must fill in all fields "; }
?>