Jump to content

Storing input into array?


matdemo159

Recommended Posts

Hello,

I'm a total novice to HTML and am currently working on a really basic page: The user inputs a name into a form, and then based on their input, the page displays a series of images. Each character of the name corresponds to a different image output.

My initial idea for this was to store the value of each character of the name into an array, and then sequentially output the corresponding images.

However, I can't seem to find a way to store the input into an array, let alone one character at a time.

Any help would be much appreciated!

Link to comment
Share on other sites

  • 1 month later...
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
        // Loop $_FILES to exeicute all files
        foreach ($_FILES['image1']['name'] as $f => $name) {     

            if ($_FILES['image1']['error'][$f] == 0) {             
                if ($_FILES['image1']['size'][$f] > $max_file_size) {
                    $message[] = "$name is too large!.";
                    continue; // Skip large files
                }
                elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){
                    $message[] = "$name is not a valid format";
                    continue; // Skip invalid file formats
                }
                else{ // No error found! Move uploaded files 
                    if(move_uploaded_file($_FILES["image1"]["tmp_name"][$f], $path.$name))
                    //Write insert query here. image name $_FILES["image1"]["name"][$f]
                }
            }
        }
    }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...