Home > how to > how to display multiple error messages in php

How To Display Multiple Error Messages In Php

Contents

here for a quick overview

Array Error Php

of the site Help Center Detailed answers to associative array php any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up how to display an error message in an array up vote 1 down vote favorite i have this code: $allowed_extension = array('jpg', 'jpeg', 'png', 'bmp', 'tiff', 'gif'); $errors = array(); $output = array(); if(!empty($_FILES['image']['tmp_name'])){ foreach($_FILES['image']['name'] as $key => $array_value){ if(!in_array(pathinfo($_FILES['image']['name'][$key], PATHINFO_EXTENSION), $allowed_extension)){ die("Die!"); } } foreach($_FILES['image']['name'] as $key => $array_value){ $file_name = $_FILES['image']['name'][$key]; $file_size = $_FILES['image']['size'][$key]; $file_tmp = $_FILES['image']['tmp_name'][$key]; $file_extension = pathinfo($file_name, PATHINFO_EXTENSION); $file_extension = strtolower($file_extension); if (!in_array($file_extension, $allowed_extension)){ $errors[$file_name][] = "format $file_extension in image $file_name is not accepted"; continue; } if ($file_size > 2097152){ $errors[$file_name][] = "maxsize of 2MB on $file_name has reached"; } if (count($errors) == 0){ $dir = "a/b/c"; if (is_dir($dir)){ mkdir("a/b/c/tmp_images", 0755); }else{ mkdir("a/b/c", 0755); mkdir("a/b/c/tmp_images", 0755); } $path = "a/b/c/tmp_images"; $prifix = basename($file_name, "." . $file_extension); //var_dump ($prifix); $uploadfile = $path . "/" . $f

0 Vote(s) - 0 Average 1 2 3 4 5 Thread Modes Ajax to display multiple error messages. wolfgang1983 Senior Member Posts: 381 Threads: 163 Joined: Oct 2014 Reputation: 5 #1 03-26-2016, 09:39 PM I have a multiple upload function using json, on my view each file that has a error should display the file upload error message. I can see that if http://stackoverflow.com/questions/10111687/how-to-display-an-error-message-in-an-array I upload 3 images and all 3 images have errors only 2 of the messages will display on the view. I use ajax to submit my form. How can I make sure that if all 3 images would display error messages for all 3 rather than just 2 http://forum.codeigniter.com/thread-64797.html on view. Ajax Script Code:

 

© Copyright 2019|winbytes.org.