I got a problem here about upload larger file in my server.I go through a lot of related questions here but i still got the same problem. I increase all the necessary php.ini in the server and when i upload larger file for only 38MB the system cannot upload it.What i do wrong here. Please help Thanks in advance.
$allowedExts = array("mp4", "MP4");
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if ((($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "video/MP4"))
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists('/home/hyborg/public_html/vimeo2/upload/' . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], '/home/hyborg/public_html/vimeo2/upload/' . $_FILES["file"]["name"]);
echo "Upload Success" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Sorry something wrong with your upload";
}
Did you make all the appropriate changes? upload_max_filesize
and post_max_size
Also you should change the max_input_time
,as upload.PHP scripts normally time-out after 30 seconds.For larger files to upload it takes much time.Try increasing the max_execution_time
to something like 500 (in sec).
Then you have to define the constraints within your PHP application:
ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);
PHP also provides a set_time_limit() function so you don’t need to set max_execution_time directly.
Setting the options in your PHP code is possibly more practical, since you can extend the execution time and increase the file size when your application is expecting a large upload.