php - File upload not working for all files -


i'm using code below upload files allowed extension under 5mb. using code, doc or pdf etc not uploading! example: 4.78mb docx file or windows phone 1.64 mb jpg not uploading!

$allowedexts = array("gif", "jpeg", "jpg","png","pdf","doc","docx","txt","rtf","bmp","psd","zip","rar","ppt","pptx");  $extension = end(explode(".", $_files["file"]["name"]));  if (in_array($extension, $allowedexts) && $_files["file"]["size"]<5242880 && $_files["file"]["error"]<=0) {     $rand = rand(000,999);     $tempfile = $_files["file"]["name"];     $file = $time . "=" . $rand . "=" . $tempfile;      if(file_exists("upload/".$file)) {         header("location:home.php?error=error");      } else {         move_uploaded_file($_files["file"]["tmp_name"],"upload/".$file);     } } else {     header("location:home.php?error=error"); //this gets executed doc or pdf files ! } 

for file "holidays.docx'" seems me file exceeds upload_max_filesize. @ least var_dump said $_files['file']['error'] equal 1 (upload_err_ini_size)

you should chech php.ini settings upload_max_filesize , post_max_size because actual limit of how large file can uploaded server. default upload_max_filesize = 2m 5mb limit means nothing.

also can use ini_get('upload_max_filesize'); runtime setting.
if unsure php.ini configuration file located use phpinfo().

also know php return $_files['file']['size'] equal 0 if file exceeds file size limit - happened.

so imo working should be. should post more var_dump() infos other files don't upload.

also note, don't check file extensions in case-insensitive manner files extensions .docx not accepted script.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -