Problema de carga de archivos php .flv

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>

Muchas gracias.
Shibbir

preguntado el 31 de enero de 12 a las 08:01

2 Respuestas

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).

Respondido el 31 de enero de 12 a las 12:01

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

Thanks a lot @Ben I fix it :) - user1161867

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";
}

Respondido el 31 de enero de 12 a las 13:01

Hello @Jeff now it's doesn't upload .flv file! - user1161867

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? - Jeff

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. - Jeff

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.