Friday, 15 January 2010

video - Uploading mp4 files using PHP -



video - Uploading mp4 files using PHP -

i able upload png/jpegs/images using php upload script not able upload mp4 files on local server. script not displaying error.

<?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); //include authentication here/ gmail solution //check if it's not allowing other extenstion other mp4 $allowedexts = array("gif", "jpeg", "jpg", "png","mp4"); $temp = explode(".", $_files["file"]["name"]); print_r($_files["file"]["type"]); $extension = end($temp); if ((($_files["file"]["type"] == "image/gif") || ($_files["file"]["type"] == "image/jpeg") || ($_files["file"]["type"] == "image/jpg") || ($_files["file"]["type"] == "image/pjpeg") || ($_files["file"]["type"] == "image/x-png") || ($_files["file"]["type"] == "image/png")) || ($_files["file"]["type"] == "video/mp4")) && ($_files["file"]["size"] < 200000) && 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("uploads/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " exists. "; } else { move_uploaded_file($_files["file"]["tmp_name"], "uploads/" . $_files["file"]["name"]); echo "stored in: " . "uploads/" . $_files["file"]["name"]; } } } else { echo "invalid file"; } ?> come in code here changed code <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); //include authentication here/ gmail solution //check if it's not allowing other extenstion other mp4 $allowedexts = array("gif", "jpeg", "jpg", "png","mp4"); $temp = explode(".", $_files["file"]["name"]); print_r($_files["file"]["type"]); $extension = end($temp); if (($_files["file"]["size"] < 200000)) { 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("uploads/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " exists. "; } else { move_uploaded_file($_files["file"]["tmp_name"], "uploads/" . $_files["file"]["name"]); echo "stored in: " . "uploads/" . $_files["file"]["name"]; } } } else { echo "invalid file"; } ?>

still same error

video/mp4invalid file

if code not have errors, please create sure increment post_max_size , load_max_filesize , memory_limit

post_max_size upload_max_filesize memory_limit

see handling file uploads: mutual pitfals explains in detail , how calculate values.

php video upload mp4

No comments:

Post a Comment