Canman2005 Posted September 6, 2008 Share Posted September 6, 2008 Hi all This code is really bugging me and ive been cracking at it for hours now and cannot seem to figure out the issue. The rules for the code are that it must be a flv file under 4MB, but for some reason it doesnt bring any error up if I upload a 38MB RAR file, but brings up an error for example if I upload a 20KB FLV file for example. It's totally random on the error front. Can anyone help? I should be able to fix it as I coded it if(isset($_POST['save'])) { $dir = file_exists('membersvideos/'.$_SESSION['member_id_number'].''); if($dir != 1) { mkdir('membersvideos/'.$_SESSION['member_id_number'].''); } $timedatecode = date('YmdHis'); $timedate = date('Y-m-d H:i:s'); $upload_folder = 'membersvideos/'.$_SESSION['member_id_number'].'/'; if($_FILES['videofile']['name']) { $rand1 = rand(111111111,999999999); $rand2 = rand(111111111,999999999); $ext1 = explode('.',basename($_FILES['videofile']['name'])); $filesize1 = $_FILES['videofile']['size']; $file_extension1 = strtolower(substr(strrchr($_FILES['videofile']['name'],"."),1)); if($filesize1 <= 400000) { if($file_extension1 == 'flv') { $upload_file1 = str_replace("'", "", $upload_folder.$timedatecode.$rand1.$rand2.'.'.strtolower($ext1[1])); $upload_file1_db1 = str_replace("'", "", $timedatecode.$rand1.$rand2.'.'.strtolower($ext1[1])); if (move_uploaded_file($_FILES['videofile']['tmp_name'], $upload_file1)) { $sql = "INSERT INTO `members_videos` SET `memberid`='".$_SESSION['member_id_number']."', `filename`='".$upload_file1_db1."', `album_id`='".$_POST['album_id']."', `live`=1, `timedate`='".$timedate."'"; $query = mysql_query($sql); } else { print"<script>alert ('There was a error - please try again');</script>"; print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">"; exit; } } else { print"<script>alert ('There was a error - please only add FLV videos');</script>"; print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">"; exit; } } else { print"<script>alert ('There was a error - your video must be under 4MB in size');</script>"; print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">"; exit; } } print "<meta http-equiv=\"refresh\" content=\"0;URL=done.php\">"; exit; } Much thanks in advance Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted September 6, 2008 Author Share Posted September 6, 2008 Oh the form code by the way is very simply on this one <form method="post" enctype="multipart/form-data"> <input name="videofile" type="file" id="videofile" /> <input name="album_id" type="hidden" id="album_id" value="2" /> </form> Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted September 6, 2008 Author Share Posted September 6, 2008 If you need a dump of my database table, let me know. This is a wired one Quote Link to comment Share on other sites More sharing options...
nuttycoder Posted September 7, 2008 Share Posted September 7, 2008 just a though but why not just allow flv files like this: switch ($_FILES["uploaded"]["type"]) { case $_FILES["uploaded"]["type"] == "application/octet-stream": move_uploaded_file($_FILES["uploaded"]["tmp_name"],$target); break; default: die('Wrong image type selected. Only flv files accepted!.'); } you could also check the file size in the same way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.