0

well I can upload image, mp3, mp4, .doc file etc with the following form. But it's doesn't upload .flv file. Anyone can tell me what is the problem in my code or how can i upload .flv..

<?php

$mysql_connect = mysql_connect("localhost", "root" );
mysql_select_db("vedio");

ini_set('upload_max_filesize','1000M');

if(isset($_POST['action']) == "upload")
{
$name = $_FILES['file']['name'];    
$tmp_name = $_FILES['file']['tmp_name'];    
$size = $_FILES['file']['size'];    
$type = $_FILES['file']['type'];    
$name = str_replace(" ", "", $name);



                $sql = mysql_query("INSERT INTO content VALUES('', 
'$name', '$tmp_name', '$size' )");  
                if($sql)
                {
                    echo "successfully uploaded";   
                }
                else
                {
                    echo "Something is wrong to upload";    
                }



$upload = "vedio/";
move_uploaded_file($_FILES['file']['tmp_name'], $upload . $name);
echo "<br/>";
echo $name; 
echo "<br/>";
echo $tmp_name;
echo "<br/>";
echo $size;
echo "<br/>";
echo $type;

}

?>



<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"    
enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="file" name="file" /></td>
<td><input type="submit" value="upload" name="action" /></td>
</tr>

</table>
</form>

Many Thanks.
Shibbir

2 Answers 2

1

My guess is your flv is probably just too big..

upload_max_filesize alone is not enough to set, you also need to set post_max_size otherwise your POST request will be empty and your upload will fail (it'll essentially look like a non-post request).

Sign up to request clarification or add additional context in comments.

1 Comment

It's just 14.7MB, is it the problem??
0

This line doesn't make sense

if(isset($_POST['action']) == "upload") 

you are calling isset() which is going to return true or false depending upon if that variable is given a value and then you compare that true or false with the string "upload" which obviously would never be equal. You either need to check if the variable is set or check if the value is equal to "upload".

if(isset($_POST['action']) && $_POST['action'] == "upload")

Should also check for file upload errors. Something like:

if ($_FILES["file"]["error"] > 0) {
    echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else {
    echo "No file upload errors";
}

3 Comments

Hello @Jeff now it's doesn't upload .flv file!
I don't see anything else blatantly wrong with your code. Does the upload directory exist and do you have the correct permissions for it? I would test your code first with uploading some other kind of file small in size to make sure your code is working at all before you determine it is a problem just with flash video files. Are you seeing any of your echo statements print out?
Also with writing code for uploading files you should really wrap everything inside your first if statement inside another if to check for file upload errors. This would allow you to see if/what errors are occuring.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.