Jump to content

I'm choking, please help - file upload


Canman2005

Recommended Posts

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.