madmatter23
03-02-2008, 12:40 AM
This is strange. I have a script that allows a user to update a 'show' database entry by attaching a video file to it.
It works fine with a 5mb file, but it fails with a 14mb file. The max file size is set to 400000000 bytes, about 38mbs. My host informs me that there is no maximum limit placed on user file uploads (I host with bluedomino.com).
The most confusing part about the failure is the error message that it generates. Instead of a server error, file size error, or even the message that I have set for !move_uploaded_file, I get this error "Error: command '' unknown".
Now you're going to have to look at my code to understand why that's so strange. Here's the condensed version.
The form page:
echo "<br><form name=showform action=\"../ttadmin/admin_show.php?action=update" method=\"post\" enctype=\"multipart/form-data\"> \n";
echo "<p>Category: <input name=f4 type=text size=50 value=".$category.">\n";
echo "<p>Upload new audio? <input type=\"checkbox\" name=\"audiocheck\" value=\"checked\"></p> \n";
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"40000000\">";
echo "<p>Audio File:<input type=\"file\" name=\"audio\"></p>\n";
echo "<p>Upload new video? <input type=\"checkbox\" name=\"videocheck\" value=\"checked\"></p> \n";
echo "<p>Video File:<input type=\"file\" name=\"video\"></p>\n";
echo "<br><input name=\"action\" value=\"update\" type=\"hidden\">\n";
echo "<br><input type=\"submit\" value=\"Update Data\" name=\"submit\">\n";
echo "<input type=\"reset\" name=\"reset\">\n";
echo "<input type=\"button\" value=\"Cancel\" onclick=\"history.back()\">\n";
echo "</form>";/**/
echo "<br /><br /> ** Please only click submit once. If you are uploading files, it may take up to 15 minutes for the update to complete.";
the uploading script:
$action = trim(strip_tags($_GET["action"]));
switch ($action) {
case "update":
echo "debug: \$action = $action";
$query = "update $showtable set topic ='$f0',showdate='$f1',starttime='$f2',endtime='$f3',moduser='$mod',category='$f4'";
if ($_POST['videocheck'] == "checked"){
echo "VIDEO UPDATE";
if (isset($_FILES['video']) && $_FILES['video']['name'] != ""){
$video = $_FILES['video']['name'];
if (!preg_match('/swf/',$video)){
die ("Error: Your uploaded file must in .swf format. Other file types are not allowed<br /> Your file must not exceed 38mb in size.");
}
$target_folder = $_SERVER['DOCUMENT_ROOT']."/show_video/";
$target_path = $target_folder.basename($_FILES['video']['name']);
$SQLVideoPath = "show_video/".basename($_FILES['video']['name']);
if(move_uploaded_file($_FILES['video']['tmp_name'], $target_path)) {
chmod("$target_path",0777);
echo "The file ".basename($_FILES['video']['name'])." has been uploaded!<br><br>";
$video_path = $target_path;
$video_path = stringCheck($video_path);
$query = $query.",video='$SQLVideoPath'";
$VIDEO = TRUE;
}
else{
echo "There was an error uploading the file, please try again!";
}
}
}
$query = $query." WHERE $pkshow = $id";
echo $query;
mysql_query($query) or die(mysql_error());
echo "<br>The show information has been updated.";
break;
default:
echo "Error: command <b>'".$action."'</b> unknown";
break;
}
Ok so again, I'm getting the error "Error: command '' unknown." To me this indicates that it didn't receive the GET variable $action, which should equal "update" and cause the case "update" code to execute.
But... I know that my code does relay that variable. It works with a small file! How could a larger file throw that off? It doesn't make any sense to me.
I'd really appreciate any help that could be offered. Ideas, advice, answers, etc. Thanks a lot!
It works fine with a 5mb file, but it fails with a 14mb file. The max file size is set to 400000000 bytes, about 38mbs. My host informs me that there is no maximum limit placed on user file uploads (I host with bluedomino.com).
The most confusing part about the failure is the error message that it generates. Instead of a server error, file size error, or even the message that I have set for !move_uploaded_file, I get this error "Error: command '' unknown".
Now you're going to have to look at my code to understand why that's so strange. Here's the condensed version.
The form page:
echo "<br><form name=showform action=\"../ttadmin/admin_show.php?action=update" method=\"post\" enctype=\"multipart/form-data\"> \n";
echo "<p>Category: <input name=f4 type=text size=50 value=".$category.">\n";
echo "<p>Upload new audio? <input type=\"checkbox\" name=\"audiocheck\" value=\"checked\"></p> \n";
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"40000000\">";
echo "<p>Audio File:<input type=\"file\" name=\"audio\"></p>\n";
echo "<p>Upload new video? <input type=\"checkbox\" name=\"videocheck\" value=\"checked\"></p> \n";
echo "<p>Video File:<input type=\"file\" name=\"video\"></p>\n";
echo "<br><input name=\"action\" value=\"update\" type=\"hidden\">\n";
echo "<br><input type=\"submit\" value=\"Update Data\" name=\"submit\">\n";
echo "<input type=\"reset\" name=\"reset\">\n";
echo "<input type=\"button\" value=\"Cancel\" onclick=\"history.back()\">\n";
echo "</form>";/**/
echo "<br /><br /> ** Please only click submit once. If you are uploading files, it may take up to 15 minutes for the update to complete.";
the uploading script:
$action = trim(strip_tags($_GET["action"]));
switch ($action) {
case "update":
echo "debug: \$action = $action";
$query = "update $showtable set topic ='$f0',showdate='$f1',starttime='$f2',endtime='$f3',moduser='$mod',category='$f4'";
if ($_POST['videocheck'] == "checked"){
echo "VIDEO UPDATE";
if (isset($_FILES['video']) && $_FILES['video']['name'] != ""){
$video = $_FILES['video']['name'];
if (!preg_match('/swf/',$video)){
die ("Error: Your uploaded file must in .swf format. Other file types are not allowed<br /> Your file must not exceed 38mb in size.");
}
$target_folder = $_SERVER['DOCUMENT_ROOT']."/show_video/";
$target_path = $target_folder.basename($_FILES['video']['name']);
$SQLVideoPath = "show_video/".basename($_FILES['video']['name']);
if(move_uploaded_file($_FILES['video']['tmp_name'], $target_path)) {
chmod("$target_path",0777);
echo "The file ".basename($_FILES['video']['name'])." has been uploaded!<br><br>";
$video_path = $target_path;
$video_path = stringCheck($video_path);
$query = $query.",video='$SQLVideoPath'";
$VIDEO = TRUE;
}
else{
echo "There was an error uploading the file, please try again!";
}
}
}
$query = $query." WHERE $pkshow = $id";
echo $query;
mysql_query($query) or die(mysql_error());
echo "<br>The show information has been updated.";
break;
default:
echo "Error: command <b>'".$action."'</b> unknown";
break;
}
Ok so again, I'm getting the error "Error: command '' unknown." To me this indicates that it didn't receive the GET variable $action, which should equal "update" and cause the case "update" code to execute.
But... I know that my code does relay that variable. It works with a small file! How could a larger file throw that off? It doesn't make any sense to me.
I'd really appreciate any help that could be offered. Ideas, advice, answers, etc. Thanks a lot!