php some image files cannot be uploaded -


i have problem image uploads. have checked posts on stackoverflow issue , tried people recommended in comments nothing works.

most images files works fine upload files wont work. example jpg files works , jpg files doesnt. , same png , other file extensions.

first thought size increased size 500000000 , still doesnt work... thinking maybe upload limit in php.ini.

i tried raise limit , uncomment limit , restart apache still wont work. problem?

here upload script

<?php $allowedexts = array("gif", "jpeg", "jpg", "png", "gif", "jpeg", "jpg", "png"); $temp = explode(".", $_files["file"]["name"]); $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"]["size"] < 500000000) && in_array($extension, $allowedexts)) {  if ($_files["file"]["error"] > 0) {    echo "return code: " . $_files["file"]["error"] . "<br>";  }else{    $filename = $temp[0].".".$temp[1];   $temp[0] = rand(0, 3000);   $filename;    if (file_exists("../../uploads/" . $_files["file"]["name"])) {      echo $_files["file"]["name"] . " exists. ";    }else{      $newfilename = round(microtime(true)) . '.' . end($temp);     if(move_uploaded_file($_files["file"]["tmp_name"], "../../uploads/" . $newfilename)) {       include('../config/dbconf.php');       $title = $_post['title'];       $content = $_post['content'];       $sticky = $_post['sticky'];       $stmt = $conn->prepare("insert gallery (img_name, title, content, sticky) values (?, ?, ?, ?)");       $stmt->bind_param("sssi", $newfilename, $title, $content, $sticky);       if($stmt->execute()) {         echo "the file ". basename($_files["file"]["name"]). " has been uploaded. redirected upload page !";         header('refresh:2; ../upload');       }else{         echo $stmt->error;       }     }    }  }  }else{   echo "invalid file : " . $_files["file"]["name"] . $_files["file"]["type"]; } ?> 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -