Reputation: 937
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
if($imageFileType != "mp4" && $imageFileType != "avi" && $imageFileType != "mov" && $imageFileType != "3gp" && $imageFileType != "mpeg"){
echo "File is not an image.";
$uploadOk = 0;
} else {
echo "File is an image ";
$uploadOk = 1;
}
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.1";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
Seems like everything is writen okay, but script Isn't working as It should. Tried to upload mp4,mpeg and all other formats. It uploads jpeg,torrent files but refuses to upload video files why Is that? I'm running XAMP on Windows. Where's the problem?
Upvotes: 0
Views: 529
Reputation: 937
Found the answer on my own, need to edit php.ini file:
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
Upvotes: 1