<?php
//max size of about 2 mb
define('MAX_FILE_SIZE','2000000');//2 MB
$allowed_file_types=array('image/jpg','image/png','image/jpeg');
//var_dump($_FILES['file_to_upload']);
if($_SERVER['REQUEST_METHOD']=='POST'){
if(isset($_POST['action'])){
if($_POST['action']=='upload_image'){
//if($_FILES['file_to_upload']['error']){
//}
if(isset($_FILES['file_to_upload'])){
$file_arr=$_FILES['file_to_upload'];
$check=false;
echo $file_arr['type'];
//for allowing image type only
foreach($allowed_file_types as $type){
if($file_arr['type']==$type){
$check=true;
}
}
if($check){
//checking size limit
if($file_arr['size']>MAX_FILE_SIZE){
echo "<p class='warning'>The file size is above limit. Optimize the image and upload again.</br>Your File Size:".round(($file_arr['size']/1000000),2)."MB<br/>Allowed File Size: ".round((MAX_FILE_SIZE/1000000),2)."MB</p>";
}else{
upload_form($file_arr);
}
}else{
echo "<p class='warning'>".$file_arr['type']." type of file is not allowed to upload</p>";
}
}
}
}
}
I am using this code to get information about file for uploading from a form. Basically what happens is when i select a file greater than 2.7/3 mb the var_dump i have used on the $_FILES return null. This is working on all other files less than that size. I get proper array from $_FILES. What may be causing this to happen? any suggestions?
BTW php.ini max_upload_size==65M