*/}}
Browse Source

fix capitalized JPG uploads

YimingWu 4 months ago
parent
commit
7a9b58212f
1 changed files with 7 additions and 7 deletions
  1. 7 7
      index.php

+ 7 - 7
index.php

@@ -1228,7 +1228,7 @@ blockquote{border-left:2px solid black;}
             return -1;
         }else{
             $ext=pathinfo($_FILES['upload_file_name']['name'],PATHINFO_EXTENSION);
-            if(!in_array($ext,['jpg','jpeg','png','gif','mp4'])) return 0;
+            if(!in_array($ext,['jpg','JPG','jpeg','png','gif','mp4'])) return 0;
             $fp = fopen('.la_lock',"w");
             while (!flock($fp, LOCK_EX| LOCK_NB)){
                 usleep(10000);
@@ -1239,7 +1239,7 @@ blockquote{border-left:2px solid black;}
             }
             $base = 'images/'.$num;
             $thumb = 'images/thumb/'.$num;
-            $use_ext=($ext=='gif' || $ext=='mp4')?('.'.$ext):('.jpg');
+            $use_ext=($ext=='gif' || $ext=='mp4')?('.'.strtolower($ext)):('.jpg');
             $final_path = $base.$use_ext; $final_thumb = $thumb.$use_ext; $i=0;
             if(!$replace) while(file_exists($final_path)){
                 $final_path = $base.strval($i).$use_ext; $final_thumb = $thumb.strval($i).$use_ext; $i++;
@@ -4080,11 +4080,11 @@ blockquote{border-left:2px solid black;}
             }
             function AddImageFile(blob){
                 var ext="";
-                if(blob.name.match(/png$/))ext = 'png';
-                else if(blob.name.match(/jpg$/))ext = 'jpg';
-                else if(blob.name.match(/jpeg$/))ext = 'jpeg';
-                else if(blob.name.match(/gif$/))ext = 'gif';
-                else if(blob.name.match(/mp4$/))ext = 'mp4';
+                if(blob.name.match(/png$/i))ext = 'png';
+                else if(blob.name.match(/jpg$/i))ext = 'jpg';
+                else if(blob.name.match(/jpeg$/i))ext = 'jpeg';
+                else if(blob.name.match(/gif$/i))ext = 'gif';
+                else if(blob.name.match(/mp4$/i))ext = 'mp4';
                 else  return;
                 var fd = new FormData();
                 blob.name = blob.name=generateUID().toString();