Reputation: 715
I am working on a laravel store image function. Fortunately it is working. But my problem is when I'm trying to upload atleast 20+ images. It only stores the first 20 images.
My question is, is there any settings that restricts my code to upload 20+ more files ?
Here is my code
public function storeImages($keycode, $projectsID){
if(!empty($_FILES[$keycode]['name']) && isset($_FILES[$keycode]) && is_array($_FILES[$keycode]['name'])):
for($i = 0; $i < count($_FILES[$keycode]['name']); $i++):
$filename = preg_replace("/[^a-z0-9A-Z\.]/","_",$_FILES[$keycode]['name'][$i]);
move_uploaded_file($_FILES[$keycode]['tmp_name'][$i],"uploads/projects/".$filename); //stores original size
try{
if(trim($filename) != ""){
$img = \Image::make("uploads/projects/".$filename); //opens the original sizes
$img->resize(200,200); // resize original
$img->save('uploads/projects/200x200_'.$filename); // save resize images
$new = array();
$new['id'] = \App\Helper\ModelHelper::uuid();
$new['project_id'] = $projectsID;
$new['type'] = "BEFORE";
$new['img_name'] = $filename;
DB::table("projects_photos")->insert($new);
}
}catch(Exception $e){
}
endfor;
endif;
}
Upvotes: 0
Views: 183
Reputation: 1
public static function Uploaduserimage($input=array(),$request){
if ($request->hasFile('userimg') && $request->file('userimg')->isValid()){
$image = $request->file('userimg');
$image_ext = $image->getClientOriginalExtension();
$imagetxt= array('gif','png','bmp','jpeg','jpg');
if(!in_array( $image_ext,$imagetxt)){
return false;
}
else{
$folderPath = base_path()."/public/your image path";
if(!is_dir($folderPath)) {
mkdir($folderPath,0777,true);
chmod($folderPath,0777);
$folderPath = $folderPath;
} else {
$folderPath = $folderPath;
}
$image_Path=$folderPath;
$newimg_name = substr(mt_rand(),0,5).time().".".$image_ext;
$request->file('userimg')->move($image_Path, $newimg_name);
if(!empty($newimg_name))
$obj->image=$newimg_name;
if($obj->save()){
return true;}
else
return false;
}
}
}
Upvotes: 0
Reputation: 20229
In php.ini
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
Change this and restart apache/nginx server
Upvotes: 1